Reputation: 107
I am now making a NestJS app and in the common boilerplate it has the src and test folders, src has the source code, each folder inside it is a module, and each module has tests for the controllers and services inside it.
But the test folder that is outside src
folder is used only for e2e tests, but when I run yarn test
in the root directory, it only runs tests from the src
directory.
How can I run the e2e tests?
Upvotes: 2
Views: 3603
Reputation: 1
To Run E2E test file you need to run below code in terminal as given below:
npm run test:e2e
Upvotes: 0
Reputation: 74
You need to run the following script on your terminal:
npm run test:e2e
Make sure that the script is defined in your package.json like this:
jest --config ./test/jest-e2e.json
Upvotes: 2
Reputation: 1214
So create a jest.config.js
in the root of module and use testMatch
property which accept an array and then you can define the files which end with spec.ts then run them.
// jest.config.js
{
testMatch: ['**/*.spec.ts'],
testEnvironment: 'node',
...
}
By using this property, it will run tests outside the src
folder.
Upvotes: 0