繁体   English   中英

赛普拉斯不允许可配置的测试

[英]Cypress Not Allowing Configurable Tests

我希望赛普拉斯为以下哈希中的每个项目自动生成一个 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 Real World App 中有一个示例,这是一个支付应用程序,用于演示 Cypress 测试方法、模式和工作流的实际使用情况 该示例在事务提要规范中,并使用lodash each来迭代feedViews对象并为每个提要动态生成测试。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM