I want to run testcafe tests concurrently BUT only executing against 1 file at a time. In other words, I want to wait for all the tests of a specific fixture to be done executing before the tests from the next fixture start executing. How do I do it?
Asked
Active
Viewed 344 times
1 Answers
4
You can do this using the TestCafe programming interface.
Please see the following example:
const createTestCafe = require('testcafe');
let testcafe = null;
let runner = null;
createTestCafe('localhost', 1337, 1338)
.then(tc => {
testcafe = tc;
runner = tc.createRunner()
.browsers('chrome')
.concurrency(3);
})
.then(() => {
return runner.src('fixture1.js').run();
})
.then(() => {
return runner.src('fixture2.js').run();
})
.then(() => {
testcafe.close();
});
However, please note that I run tests twice in sequence here. That means that your browsers will be opened twice too. You will also get two different reports.

Alex Kamaev
- 6,198
- 1
- 14
- 29
-
Could you please describe what you mean by saying: "grouped multiple test files using meta tag"? If you run tests as @Alex Kamaev suggested: `return runner.src('fixture1.js').run();`, you can be sure that there is only one file that is executed at a time. – aleks-pro Jul 11 '19 at 14:17
-
Where will I create this class with the code you posted? – Gurkirat Singh Mar 30 '20 at 20:53
-
Moreover, I don't want to hard code every test file name. I put all my tests under a folder and just specify that folder in the CLI which runs all the tests under it. I want testcafe to wait and move to next test file only once the previous test file has been compltely executed. – Gurkirat Singh Mar 30 '20 at 21:19