Is there a way to make tests run as soon as a browser is connected? Currently if you run tests in multiple browsers at the same time, browsers wait for each other before running the tests.
This is not desirable for us since we use browserstack and our license only allows one connection at a time, but we want to run the tests in five different browsers. So we would like to run the tests in these browsers sequentially.
Is there a possibility to do this (e.g. by passing some option to the test run)?
At present, you can do it by running TestCafe for each browser.
testcafe "browserstack:[email protected]:Windows 10" /tests
testcafe "browserstack:[email protected]:Windows 10" /tests
testcafe "browserstack:Internet [email protected]:Windows 10" /tests
etc.
TestCafe does not allow running tests in several browsers sequentially at the level of one test run.
聽
聽
聽
I hope it's alright to add this code snippet to this closed issue.
@Lukas-Kullmann
I've figured out a way to do this in a scripted node application using async/await. Please see the code below
const browsers = [
['browserstack:[email protected]:Windows 10', 'browserstack:[email protected]:Windows 10'],
['browserstack:[email protected]:Windows 10', 'browserstack:[email protected]:OS X High Sierra'],
['browserstack:[email protected]:OS X High Sierra', 'browserstack:[email protected]:OS X High Sierra'],
];
const runTest = async browser => {
console.log('starting tests');
await createTestCafe('localhost', 1337, 1338)
.then(tc => {
testcafe = tc;
const runner = testcafe.createRunner();
return runner
.src(['web-tests/*.ts'])
.browsers(browser)
.run();
})
.then(async failedCount => {
console.log('Tests failed: ' + failedCount);
await testcafe.close();
return;
});
}
const runAllBrowsers = async () => {
for (const browser of browsers) {
await runTest(browser);
}
}
Adjust the browsers array to include the browsers you want to execute your tests against. The array may be a list of strings, or arrays containing browsers to run parallel. In my case, I can reliably run against 2-3 browsers synchronously.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs or feature requests. For TestCafe API, usage and configuration inquiries, we recommend asking them on StackOverflow.
Most helpful comment
I hope it's alright to add this code snippet to this closed issue.
@Lukas-Kullmann
I've figured out a way to do this in a scripted node application using async/await. Please see the code below
Adjust the browsers array to include the browsers you want to execute your tests against. The array may be a list of strings, or arrays containing browsers to run parallel. In my case, I can reliably run against 2-3 browsers synchronously.