Ava: Parallel and serial test running in one command

Created on 10 Nov 2016  路  5Comments  路  Source: avajs/ava

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.

question

Most helpful comment

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 => {});

All 5 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sindresorhus picture sindresorhus  路  4Comments

fleg picture fleg  路  3Comments

niftylettuce picture niftylettuce  路  4Comments

fregante picture fregante  路  3Comments

carpasse picture carpasse  路  3Comments