Skip to content

Commit

Permalink
fix jest and cypress global type definitions clashing in IntelliJ
Browse files Browse the repository at this point in the history
  • Loading branch information
halbekanne committed Jan 7, 2024
1 parent 22d2d06 commit c9e2827
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 15 deletions.
21 changes: 21 additions & 0 deletions src/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "./out-tsc/spec",
"module": "CommonJs",
"skipLibCheck": true,
"emitDecoratorMetadata": true
},
"files": [
"polyfills.ts"
],
"include": [
"**/*.spec.ts",
],
"exclude": [
// This is to prevent global types clashing between jest and cypress
// See: https://github.com/cypress-io/cypress/issues/22059#issuecomment-1148921141
"../cypress.config.ts",
]
}
24 changes: 9 additions & 15 deletions tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
/* To learn more about this file see: https://angular.io/config/tsconfig. */
/* Having the real tsconfig.spec.json under src is a workaround, as in IntelliJ,
* the *.spec.ts files would otherwise be compiled with tsconfig.app.json,
* which would lead to a clash of global types for tests that both cypress and jest define.
*
* See:
* - https://stackoverflow.com/questions/58999086/cypress-causing-type-errors-in-jest-assertions/72663546#72663546
* - https://youtrack.jetbrains.com/issue/WEB-43373/IntelliJ-not-correctly-interpreting-standard-ng-cli-tsconfig-setup
*/
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./out-tsc/spec",
"module": "CommonJs",
"types": ["jest"],
"skipLibCheck": true,
"emitDecoratorMetadata": true
},
"files": ["src/polyfills.ts"],
"include": [
"src/**/*.spec.ts",
"src/**/*.d.ts",
"../node_modules/@types/jest"
]
"extends": "./src/tsconfig.spec.json"
}

0 comments on commit c9e2827

Please sign in to comment.