设想:
我使用 API 运行用代码封装的 TestCafé
我有一个想要参数化的测试,使用不同的动态值进行测试。
Problem
Testcafé 不支持向测试发送参数。有没有办法注入值?
您可以使用进程.env将参数从运行程序脚本传递给 TestCafe 测试。
//test.js
const createTestCafe = require('testcafe');
(async => {
process.env.foo = 'bar';
const testcafe = await createTestCafe();
await testcafe
.createRunner()
.src('test.js')
.browsers('chrome')
.run();
await testcafe.close();
})()
//test.js
fixture `Examples`;
test('process.env', async t => {
console.log(process.env.foo);
});
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)