Testing 正在运行冒烟测试,但在尝试创建4个删除操作时出错
我正在关注Cypress,我们正在测试“待办事项”应用程序。我创建的测试应该从我创建的db.json文件中删除所有项,添加todo项,然后最后删除所有项,共四项。我在每次删除操作后添加了cy.wait。 但是,我得到以下错误:Testing 正在运行冒烟测试,但在尝试创建4个删除操作时出错,testing,cypress,Testing,Cypress,我正在关注Cypress,我们正在测试“待办事项”应用程序。我创建的测试应该从我创建的db.json文件中删除所有项,添加todo项,然后最后删除所有项,共四项。我在每次删除操作后添加了cy.wait。 但是,我得到以下错误: Assert: expected [<li>, 3 more...] not to exist in DOM describe('Smoke tests', () => { beforeEach(() => {
Assert: expected [<li>, 3 more...]
not to exist in DOM
describe('Smoke tests', () => {
beforeEach(() => {
cy.request('GET', '/api/todos')
.its('body')
.each(todo => cy.request('DELETE', `/api/todos/${todo.id}`))
})
context('With new todos', () => {
it.only('Save new todos', () => {
const items = [
{text: 'Buy Milk', expectedLength: 1},
{text: 'Buy Eggs', expectedLength: 2},
{text: 'Buy bread', expectedLength: 3}
]
cy.visit('/')
cy.server()
cy.route('POST', '/api/todos')
.as('create')
cy.wrap(items)
.each(todo => {
cy.focused()
.type('todo.text')
.type('{enter}')
cy.wait('@create')
cy.get('.todo-list li')
.should('have.length', todo.expectedLength)
})
})
context('With active todos', () => {
beforeEach(() => {
cy.fixture('todos')
.each(todo => {
const newTodo = Cypress._.merge(todo, {isComplete: false})
cy.request('POST', '/api/todos', newTodo)
})
cy.visit('/')
})
it('Loads existing data from DB', () => {
cy.get('.todo-list li')
.should('have.length', 4)
})
it.only('Deletes todos', () => {
cy.server()
cy.route('DELETE', '/api/todos/*')
.as('delete')
cy.get('.todo-list li')
.each($el => {
cy.wrap($el)
.find('.destroy')
.invoke('show')
.click()
cy.wait('@delete')
})
.should('not.exist')
})
})
})
})