I have my regular unit tests in folders with my services
Now I created new folder called integration/
and inside this folder all my tests look like anotherFolder/testSomeApi.integration.js
I did this, so that when I call node jest
, it runs all the unit tests but not the integration tests. I want to call integration tests from my docker container with separate command
How can I call something like jest *integration.js
so that all tests in integration folder with extension integration.js
gets called?
Inside your integration folder create a config file for jest, eg jest-integration.json
{
"rootDir": ".",
"testEnvironment": "node",
"testRegex": ".integration.js$",
}
Now you can run jest from your project root like so:
jest --config ./integration/jest-integration.json
You could save this line as an NPM script in your package.json and use it like
npm run test:integration
.
最后我做了
jest "(/integration/.*|\\\\.(integration))\\\\.(js)$"
jest --testPathPattern=".*/folderName/.*.spec.ts"
为我工作。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.