Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parallel and serial test running in one command #1107

Closed
kostia-official opened this issue Nov 10, 2016 · 5 comments
Closed

Parallel and serial test running in one command #1107

kostia-official opened this issue Nov 10, 2016 · 5 comments
Labels

Comments

@kostia-official
Copy link

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.

@vadimdemedes
Copy link
Contributor

Hey! You can use .serial() test modifier to run selected tests serially:

test.serial('requires to run serially', t => {
  // ...
});

@sindresorhus
Copy link
Member

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

@kostia-official
Copy link
Author

kostia-official commented Nov 14, 2016

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

@sindresorhus
Copy link
Member

before hooks always run before the tests.

@vadimdemedes
Copy link
Contributor

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: #1107 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants