When using absolute import paths in my test files, Intellij resolves correctly but the Testcafe compiler throws an error. Interestingly, no errors are thrown when using absolute paths within the application source files.
I'm wondering what could be causing this issue?
Here are the versions I am using:
"typescript": "~3.9.10",
"testcafe": "^1.16.0",
"@angular/core": "~10.2.5"
This is how my project structure looks like:
angular
├── e2e/
│ ├── tsconfig.json
│ └── src
│ ├── noResults.ts
│ └── test.e2e-spec.ts
├── node_modules/
├── src/
│ └── <project files>
├── tsconfig.json
├── testcaferc.json
Here is my tsconfig configuration:
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"downlevelIteration": true,
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"module": "es2020",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"importHelpers": true,
"target": "es2015",
"noUnusedLocals": false,
"noUnusedParameters": false,
"typeRoots": ["node_modules/@types"],
"lib": ["es2018", "es2015", "dom"],
"noImplicitAny": true,
"strictNullChecks": true,
"charset": "utf8",
"newLine": "lf",
"allowSyntheticDefaultImports": true
},
"angularCompilerOptions": {
"fullTemplateTypeCheck": true,
"preserveWhitespaces": true,
"strictTemplates": true
}
}
This is how my e2e/tsconfig.json file is configured:
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../dist/out-tsc/e2e",
"target": "ESNext",
"sourceMap": false,
"resolveJsonModule": true,
"esModuleInterop": true
}
}
My testcaferc.json setup is as follows:
{
"compilerOptions": {
"typescript": {
"configPath": "./e2e/tsconfig.json"
}
}
}
In my e2e/src/test.e2e-spec.ts file, I have the following import statement:
import { noResults } from 'e2e/src/no-results';
The export in my e2e/src/noResults.ts file looks like this:
export const noResults = () => {...}
Unfortunately, I encountered this error:
- /home/IdeaProjects/angular/node_modules/testcafe/lib/cli/index.js
at Object.<anonymous> (/home/IdeaProjects/angular/e2e/src/test.e2e-spec.ts:7:1) {
code: 'E1035',
data: [
"Error: Cannot find module 'e2e/src/noResults'\n" +
'Require stack:\n' +
'- /home/IdeaProjects/angular/e2e/test.e2e-spec.ts\n' +
'- /home/deaProjects/angular/node_modules/testcafe/lib/compiler/test-file/formats/es-next/compiler.js\n' +
'- /home/IdeaProjects/angular/node_modules/testcafe/lib/compiler/compilers.js\n' +
'- /home/IdeaProjects/angular/node_modules/testcafe/lib/compiler/index.js\n' +
'- /home/IdeaProjects/angular/node_modules/testcafe/lib/runner/bootstrapper.js\n' +
'- /home/IdeaProjects/angular/node_modules/testcafe/lib/runner/index.js\n' +
'- /home/IdeaProjects/angular/node_modules/testcafe/lib/live/test-runner.js\n' +
'- /home/IdeaProjects/angular/node_modules/testcafe/lib/testcafe.js\n' +
'- /home/IdeaProjects/angular/node_modules/testcafe/lib/index.js\n' +
'- /home/IdeaProjects/angular/node_modules/testcafe/lib/cli/cli.js\n' +
'- /home/IdeaProjects/angular/node_modules/testcafe/lib/cli/index.js'
]
}