在每个环境中使用不同的URL运行相同的Testcafe测试

问题描述 投票:2回答:1

我正在研究TestCafe的概念证明。我在一个测试环境中有一些测试。我需要一种方法,以在最多3个具有不同URL的不同测试环境中运行相同的测试。这种情况下有最佳实践吗?

automation automated-tests e2e-testing testcafe web-testing
1个回答
2
投票

一种解决方案是在testcafe命令行上添加自定义选项,例如:--env=uat

使用minimist读取已添加到TestCafe命令行的所有自定义选项,并像这样导出配置对象:

import * as minimist from 'minimist';

const args = minimist(process.argv.slice(2));

// get the options --env=xxx --user=yyy from the command line
export const config = {
  env: args.env,
  user: args.user,
};

然后将您需要的config对象导入测试代码中。

请参阅How do I work with configuration files and environment variables?了解更多详细信息。

© www.soinside.com 2019 - 2024. All rights reserved.