I'd like to set two different environments and be able to run both in watch mode.
|-- /server | |-- index.js <- Node |-- /client | |-- index.js <- jsdom |-- package.json
Actually I run jest twice for each environment, providing a different config file for each:
$ yarn test -- --config=server.config.json $ yarn test -- --config=client.config.json
But this doesn't let me run both at the same time.
By the way @trusktr Jest DOES run tests in parallel, just not ones in the same file. So you can run into issues with interference between tests if they are running on the same database.
Once the describe blocks are complete, by default Jest runs all the tests serially in the order they were encountered in the collection phase, waiting for each to finish and be tidied up before moving on.
rootDir [string] Default: The root of the directory containing the package.json or the pwd if no package.json is found. Please provide your exact Jest configuration and mention your Jest, node, yarn/npm version and operating system.
By default, jest uses the node testEnvironment. This essentially makes any tests meant for a browser environment invalid. jsdom is an implementation of a browser environment, which supports these types of UI tests.
EDIT (Jan 2018):
It is now possible to do so (since Jest v20), and the option is called projects
. Read more about it the docs.
Basically you can define an array of your projects you want Jest to be run within:
{ "projects": ["<rootDir>/client", "<rootDir>/server", "<rootDir>/some-glob/*"] }
Just remember every project needs to have its own config. If you want the config to be picked up automatically, put it inside jest.config.js
file or like usually in package.json
.
If you prefer placing your config somewhere else (e.g. in configs/jest.js
), you'll need to point to the path of the config file (with the rootDir
option set properly):
{ "projects": ["<rootDir>/client/configs/jest.js", "<rootDir>/server/configs/jest.js"] }
ORIGINAL ANSWER:
Currently this is not possible, but there's an issue for that case: https://github.com/facebook/jest/issues/1206.
Feel free to jump in and leave a comment!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With