1

我正在尝试编写一个测试,我需要检查博客列表是否按每个博客的喜欢的降序呈现。为此,我在 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()
})

赛普拉斯中的错误输出如下所示: 赛普拉斯中上述代码的输出图像

4

0 回答 0