Jest Schematic still adds `setupFile` & `tsConfig`
See original GitHub issueCurrent Behavior
When generating a project with jest it creates the correct jest.config.js
with setupFilesAfterEnv
& tsConfig
but it adds setupFile
& tsConfig
to the test architect as well.
Expected Behavior
Because setupFile
& tsConfig
options were removed from all test architects during the migration to Nx10 it seems unintended, that these options are still generated.
Steps to Reproduce
-
Generate Nx Workspace with an Angular app
npx create-nx-workspace@latest test-jest --preset="angular" --appName="test-jest"
-
Look at the
projects.test-jest.architect.test.options
in theangular.json
"test": {
"builder": "@nrwl/jest:jest",
"options": {
"jestConfig": "apps/test-jest/jest.config.js",
"tsConfig": "apps/test-jest/tsconfig.spec.json", // <-- was removed during Nx10 migration
"passWithNoTests": true,
"setupFile": "apps/test-jest/src/test-setup.ts" // <-- was removed during Nx10 migration
}
}
- The
jest.config.js
contains this information as expected
module.exports = {
name: 'test-jest',
preset: '../../jest.config.js',
setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'], // <-- `projects.test-jest.architect.test.options.setupFile`
globals: {
'ts-jest': {
tsConfig: '<rootDir>/tsconfig.spec.json', // <-- `projects.test-jest.architect.test.options.tsConfig`
stringifyContentPathRegex: '\\.(html|svg)$',
astTransformers: [
'jest-preset-angular/build/InlineFilesTransformer',
'jest-preset-angular/build/StripStylesTransformer',
],
},
},
coverageDirectory: '../../coverage/apps/test-jest',
snapshotSerializers: [
'jest-preset-angular/build/AngularNoNgAttributesSnapshotSerializer.js',
'jest-preset-angular/build/AngularSnapshotSerializer.js',
'jest-preset-angular/build/HTMLCommentSerializer.js',
],
};
Environment
nx : Not Found
@nrwl/angular : 10.0.11
@nrwl/cli : 10.0.11
@nrwl/cypress : 10.0.11
@nrwl/eslint-plugin-nx : Not Found
@nrwl/express : Not Found
@nrwl/jest : 10.0.11
@nrwl/linter : Not Found
@nrwl/nest : Not Found
@nrwl/next : Not Found
@nrwl/node : Not Found
@nrwl/react : Not Found
@nrwl/schematics : Not Found
@nrwl/tao : 10.0.11
@nrwl/web : Not Found
@nrwl/workspace : 10.0.11
typescript : 3.9.7
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Configuring Jest
Configuring Jest. The Jest philosophy is to work great by default, but sometimes you just need more configuration power.
Read more >Jest + Typescript + Absolute paths (baseUrl) gives error
I was struggling with the same problem and actually it turns out that a simple change seems to do the trick.
Read more >Migrating an Nx Workspace From Karma to Jest
In this article I want to describe how we can migrate an nx workspace with an angular application from karma to use jest,...
Read more >ESM Support | jest-preset-angular - GitHub Pages
mjs to add to Jest setup file to ensure that Jest can set up test environment properly. import 'jest-preset-angular/setup-jest.mjs'; ...
Read more >nrwl-nx/community - Gitter
Now I can simply yarn add @my-org/themes wherever I like to use it, ... Angular: 8.3.20 @nrwl/schematics: 8.10.0 @nrwl/jest: 9.0.4 jest: 25.1.0.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yes, I think a migration should be added again. It’ll most likely be the same set up as the original migration (without the jest config modifications 😄 )
@ZachJW34 I would have started this afternoon, but you can take it - thx 👍