【问题标题】:Cypress Not Allowing Configurable Tests赛普拉斯不允许可配置测试
【发布时间】:2020-10-04 11:01:34
【问题描述】:

我希望赛普拉斯为以下哈希中的每个项目自动生成一个 it 块。当我目前运行 cypress 时,它可以很好地进行第二次测试,但会忽略带有 while 循环的测试。我该如何解决这个问题?我宁愿不必为地图中的每个项目写出明确的 it 块。

   const testDataMappings = { 
        1: {e2eTestName: 'test-one'},
        2: {e2eTestName: 'test-two'},
        3: {e2eTestName: 'test-three'},
    }
    
// Does not work
    describe('My Tests', function () {
        let i = 1;
        while (i < testDataMappings.length + 1) {
            let entry = testDataMappings[i];
            it("Should Do The Thing Correctly For" + entry.e2eTestName, () => {
                const standardCaseUrl = Cypress.config().baseUrl + "?profile_id=" + String(i);
                cy.visit(standardCaseUrl);
                cy.wait(5000);
                cy.get('.some-div-class-name').compareSnapshot(entry.e2eTestName, 0.0);
            });
            i +=1;
        }

// works
        describe('Another Describe block', function () {
            it('Should do the thing', () => {
                const standardCaseUrl = Cypress.config().baseUrl + "?profile_id=1";
                cy.visit(standardCaseUrl);
                cy.wait(5000); 
                cy.get('.some-div-class-name').compareSnapshot('some-snapshot-name', 0.0);
            });
        });
    });

控制台日志似乎没有显示,因此对正在发生的事情没有太多了解。

【问题讨论】:

    标签: cypress e2e-testing


    【解决方案1】:

    Cypress Real World Appa payment application to demonstrate real-world usage of Cypress testing methods, patterns, and workflows中有一个例子。该示例位于 transaction feeds spec 中,并使用 lodash each 迭代 feedViews 对象并为每个提要动态生成测试。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-02-14
      • 1970-01-01
      • 2021-10-20
      • 2020-05-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多