I have some tests that are ment to be run aside from all other .test
files so I called them .integration.js
how to test all files that have .integration.js
?
example file;
endpoint.integration.js
In order to run a specific test, you'll need to use the jest command. npm test will not work. To access jest directly on the command line, install it via npm i -g jest-cli or yarn global add jest-cli . Then simply run your specific test with jest bar.
only and describe. only work only for the module they are in. If you are having problems to filter tests in multiple files, you can use jest -t name-of-spec , filtering tests that match the specified name (match against the name in describe or test).
You can configure custom test file names with the config key testRegex
.
https://jestjs.io/docs/en/configuration#testregex-string--arraystring
The default is: (/__tests__/.*|(\\.|/)(test|spec))\\.[jt]sx?$
So to only run tests in files like endpoint.integration.js
tests, you can use this regex instead: \\.integration\\.js$
You can put this in your configuration either in package.json
or jest.config.js
.
Or you can use the regex as the first argument to the jest cli command.
jest '\\.integration\\.js$'
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