我正在关注赛普拉斯的tutorial,我们正在测试“待办事项”应用程序。我创建的测试应该从我创建的db.json文件中删除所有项目,添加待办事项,最后删除所有四个项目。我在每次删除操作后添加了一个cy.wait。 但是,出现以下错误:
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')
})
})
})
})