I've encountered an issue while configuring Cypress in my Project, specifically with the typescript setup for Cypress. Here is the structure of my project:
fronend/
- cypress/
-tsconfig.json
- src/
- tsconfig.json
- package.json
- cypreess.json
This is the content of my tsconfig.json file located in the Cypress directory:
{
"extends": "../tsconfig.json",
"include": ["./**/*.ts"],
"exclude": [],
"compilerOptions": {
"types": ["cypress"],
"lib": ["es2015", "dom"],
"isolatedModules": false,
"composite": true
}
}
And this is my tsconfig.json file from the frontend directory:
{
"compilerOptions": {
"baseUrl": "src",
"rootDir": "src",
"target": "es6",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react"
},
"include": ["./src/**/*.ts", "./src/**/*.tsx", "./src/**/*.svg"],
"exclude": ["node_modules", "scripts"],
"references": [
{
"path": "./cypress/"
}
]
}
Although Cypress works fine without the line
"extends": "../tsconfig.json"
, I need it to export files from the src directory into my cypress ts files.
If you could provide some insights on what might be wrong with my configurations, that would be greatly appreciated. I'd prefer not to make changes to the main tsconfig.json file as it is responsible for running our UI.
Here is the error message I'm receiving:
File '/**/fronend/cypress/support/objects/client.ts' is not under 'rootDir' '/**/frontend/src'. 'rootDir' is expected to contain all source files.
The file is in the program because:
Imported via '../../support/client' from file '/**/frontend/cypress/integration/EndToEndTests.spec.ts'
Matched by include pattern './**/*.ts' in '/**/frontend/cypress/tsconfig.json'ts(6059)
tsconfig.json(3, 15): File is matched by include pattern specified here.