Hello. Currently I'm running tests with using this npm scripts:
"ava": "npm run ava:serial && npm run ava:parallel",
"ava:serial": "NODE_ENV=test ava -vs test/*.test.serial.js",
"ava:parallel": "NODE_ENV=test ava -v test/*.test.js",
Some tests I can run parallel and some test I can't. What about parsing serial string in file name and run them serially? It would be great, because my approach is not too fast.
Hey! You can use .serial() test modifier to run selected tests serially:
test.serial('requires to run serially', t => {
// ...
});
And if all tests in a file are serial, you can import just the serial test modifier:
import {serial as test} from 'ava';
// this is a serial test
test(t => {});
Thanks for answers but my before hooks still not work serially.
I have db clearing in my before hook that's why I can't run my test parallel.
It would be great to have one modifier for many tests of for one file. Like:
test.serial('all stuff inside of me is serial', t => {
test(t => {});
test(t => {});
});
before hooks always run before the tests.
It would be great to have one modifier for many tests of for one file.
See @sindresorhus's solution above on how to accomplish this: https://github.com/avajs/ava/issues/1107#issuecomment-260247033.
Most helpful comment
And if all tests in a file are serial, you can import just the
serialtest modifier: