schematics
schematics copied to clipboard
feat: run all app e2e tests when configuring new sub apps
When a new SubApp is added to a project the project is now configured to run all E2E tests by default. Currently it only runs the main app E2E tests.
Closes #1167.
PR Checklist
Please check if your PR fulfills the following requirements:
- [x] The commit message follows our guidelines: https://github.com/nestjs/nest/blob/master/CONTRIBUTING.md
- [x] Tests for the changes have been added (for bug fixes / features)
- [ ] Docs have been added / updated (for bug fixes / features)
PR Type
What kind of change does this PR introduce?
- [ ] Bugfix
- [x] Feature
- [ ] Code style update (formatting, local variables)
- [ ] Refactoring (no functional changes, no api changes)
- [ ] Build related changes
- [ ] CI related changes
- [ ] Other... Please describe:
What is the current behavior?
Issue Number: #1167
What is the new behavior?
It will now create a new jest-e2e.json
file in the ./apps
root directory containing references to each sub apps E2E test configs.
{
"projects": [
"apps/app-one/test/jest-e2e.json",
"apps/app-two/test/jest-e2e.json",
"apps/app-three/test/jest-e2e.json",
"apps/app-four/test/jest-e2e.json"
]
}
And updating the the test:e2e
to now run jest --config apps/jest-e2e.json
Does this PR introduce a breaking change?
- [ ] Yes
- [x] No
Other information
@kamilmysliwiec this differs from the open issue slightly because as I was testing on my own monorepo with 3 sub apps, the package.json
test:e2e
script would come out rather long and not scalable:
"test:e2e": "jest --projects ./apps/my-app/test/jest-e2e.json ./apps/my-other-app/test/jest-e2e.json ./apps/my-different-app/test/jest-e2e.json"
So instead I opted for a dedicated jest-e2e.json
that references all the different project configs.
Appreciate any and all feedback!
I should also add - why not just make the contents of ./apps/jest-e2e.json
use regex to find all the spec files and remove the config from each app.
./apps/jest-e2e.json
could look like this and do the same job with less Jest config files:
{
"moduleFileExtensions": ["js", "json", "ts"],
"rootDir": ".",
"testEnvironment": "node",
"testRegex": ".e2e-spec.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
}
}
I decided against this because I am not sure how NestJS users modify their jest-e2e.json
config per sub app. If you would prefer this approach please let me know.