There seems to be a problem with the TypeScript configuration in my Angular project causing issues with expect matchers. Interestingly, when I remove the Cypress folder from the project, the expect matchers work perfectly fine along with IntelliSense. It appears that the presence of Cypress is triggering this issue.
I believe my configuration is pretty standard. I utilize cypress-schematic
to set up the integration of Cypress with my Angular 14 project.
The errors are visible in my Karma/Jasmine *.spec.ts files. Here's a screenshot of what I'm encountering:
https://i.sstatic.net/Vxtu2.png
This is my tsconfig.json
:
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"forceConsistentCasingInFileNames": true,
"strict": false,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
...
}
Here is my tsconfig.spec.json
:
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./dist/out-tsc/spec",
"types": [
"jasmine",
"jasmine-expect",
...
]
},
...
}
And here is my Cypress cypress/tsconfig.json
:
{
"extends": "../tsconfig.json",
"include": ["**/*.ts"],
"compilerOptions": {
"sourceMap": false,
...
]
}
}
Finally, this is my karma.config
:
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
files: [
'node_modules/jasmine-expect/dist/jasmine-matchers.js'
],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
...
],
....