我正在尝试编写一个测试,其中我需要检查博客列表是否按每个博客的点赞降序呈现。为此,我用Cypress创建了3个模拟博客,并想在测试它们是否按喜欢的降序排列之前,给它们一个特定的点赞数量(3 -1- 2)。然而,下面的代码给出了4-2-2赞,而不是预期的3-1- 2:
it('the blogs are ordered in descending order of likes', function() {
cy.createBlog({
title: 'The Perks of Being a Wallflower',
author: 'Emma Watson',
url: 'www.blank.org',
})
cy.createBlog({
title: 'The Life of Pi',
author: 'Yann Martel',
url: 'www.pi.com',
})
cy.createBlog({
title: 'Deep Dive into the World of Containers',
author: 'GDG',
url: 'www.gdg.com',
})
cy.wait(750)
cy.contains('The Perks of Being a Wallflower')
.contains('view').click({ multiple: true })
.get('.blog-like-button').click({ multiple: true })
cy.wait(750)
cy.contains('The Perks of Being a Wallflower')
.get('.blog-like-button').click({ multiple: true })
cy.wait(750)
cy.contains('The Perks of Being a Wallflower')
.get('.blog-like-button').click({ multiple: true })
cy.wait(750)
cy.contains('The Life of Pi')
.contains('view').click({ multiple: true })
.get('.blog-like-button').click({ multiple: true })
cy.wait(750)
cy.contains('Deep Dive into the World of Containers')
.contains('view').click({ multiple: true })
.get('.blog-like-button').click({multiple: true})
cy.wait(750)
cy.contains('Deep Dive into the World of Containers')
.get('.blog-like-button').click({ multiple: true })
cy.wait(750)
cy.reload()
})Cypress中的错误输出如下所示:image of output of above code in Cypress
https://stackoverflow.com/questions/70024720
复制相似问题