我们可以在cypress中保存不同的环境测试数据文件吗?



我正在工作的应用程序有3个不同的环境。那么,在运行测试时,是否有办法为每个环境(QA/STG/PRD)使用特定的测试数据文件?我知道我们可以使用柏树。Env文件来指定与环境相关的数据,但是我不知道如何在不同的环境中运行时指定不同的文件。

我认为这是不可能选择哪些文件你的cypress将根据。env运行,但你可以把你的测试内容在一个IF内,所以即使cypress运行测试文件,一切都将在一个IF内,如果不满意将不执行操作。

describe('Group of tests', () => {
it('Test 1', () => {
if(env == 'dev') {
// Your test here
} else {
/* put something here so that cypress doesn't 
throw an error claiming the test suite is empty. */
}
});
});

有一个cypress-tags包可能适合你的需要。

通过向Cypress环境变量CYPRESS_INCLUDE_TAGS传递逗号分隔的标签列表来选择测试

describe(['QA'], 'Will tag every test inside the describe with the "QA" tag',
function () { ... });
it(['QA'], 'This is a work-in-progress test', function () { ... });

相关内容

最新更新