在每个环境中使用不同的URL运行相同的Testcafe测试 [英] Run Same Testcafe tests with different URLs per environment

查看:102
本文介绍了在每个环境中使用不同的URL运行相同的Testcafe测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am working on a TestCafe proof of concept. I have a few tests working in one test environment. I need a way to run the same tests in up to 3 different test environments that have different URLs. Is there a best practice for this scenario?

推荐答案

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

A solution is to add custom options on the testcafe command-line like for example : --env=uat.

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

Use minimist to read all custom options that you have added to the TestCafe command-line and export a config object like this:

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 对象

请参见如何使用配置文件和环境变量?以获取更多详细信息。

see How do I work with configuration files and environment variables? for more details.

这篇关于在每个环境中使用不同的URL运行相同的Testcafe测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆