Reputation: 31371
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
Upvotes: 7
Views: 4865
Reputation: 8678
// jest.config.ts
const config: Config = {
testRegex: ['\\.spec\\.[jt]sx?$'], // match file.spec.ts, file.spec.jsx...
...
}
\\.
)Upvotes: 0
Reputation: 23064
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$'
Upvotes: 7