Sve*_*ven 3 javascript automated-tests inject e2e-testing testcafe
设想:
\n\n我使用 API 运行封装在代码中的 TestCaf\xc3\xa9 \n我有一个想要参数化的测试,使用不同的动态值进行测试。
\n\n问题
\n\nTestcaf\xc3\xa9 不支持向测试发送参数。有没有办法注入值?
\n您可以使用process.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();
})()
Run Code Online (Sandbox Code Playgroud)
//test.js
fixture `Examples`;
test('process.env', async t => {
console.log(process.env.foo);
});
Run Code Online (Sandbox Code Playgroud)