百度cafe 测试html,testing - Running Testcafe tests in sequence with html reports - Stack Overflow...

This is not a question. I just want to share my solution for running Testcafe tests in sequence with HTML reports.

Running tests in parallel on different browsers was not a solution for me. I have to wait for tests on one env to finish, then to run on the next env.

It took me a while to figure this out, but it works for me.

If someone has better solution, please inform me.

Just add this code (with your specific custom settings) into a runner file. i.e. runner.js

and run it with node runner.js command.

The solution:

const createTestCafe = require('testcafe');

const fs = require('fs');

const browsers = [

'chrome',

'firefox'

];

let stream = null;

const runTest = async browser => {

console.log('----------------- starting tests on ' + browser);

await createTestCafe('localhost', 1337, 1338)

.then(tc => {

testcafe = tc;

const runner = testcafe.createRunner();

return runner

.src([

"./smokeTests/someTests.js"

])

.browsers(browser)

.reporter('html', stream)

.run();

})

.then(async failedCount => {

console.log('Tests failed: ' + failedCount);

await testcafe.close();

return;

});

}

const runAllBrowsers = async () => {

for (const browser of browsers) {

stream = fs.createWriteStream('./testResults' +'/report_' + browser + '.html');

await runTest(browser);

await testcafe.close();

}

}

runAllBrowsers();

I used the original idea from https://github.com/DevExpress/testcafe/issues/2495.

I'd like to thank nabrahamson for the original idea!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值