Reputation: 67
Intellij does resolve correctly but the Testcafe compiler throws an error when using absolute import paths in my test files. Using absolute paths within the application source files does not throw any errors.
What could be the problem here?
These are my versions
"typescript": "~3.9.10",
"testcafe": "^1.16.0",
"@angular/core": "~10.2.5"
This is my project structure:
angular
├── e2e/
│ ├── tsconfig.json
│ └── src
│ ├── noResults.ts
│ └── test.e2e-spec.ts
├── node_modules/
├── src/
│ └── <project files>
├── tsconfig.json
├── testcaferc.json
This is my tsconfig:
{
"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 my e2e/tsconfig.json:
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../dist/out-tsc/e2e",
"target": "ESNext",
"sourceMap": false,
"resolveJsonModule": true,
"esModuleInterop": true
}
}
This is my testcaferc.json:
{
"compilerOptions": {
"typescript": {
"configPath": "./e2e/tsconfig.json"
}
}
}
This is my import in the e2e/src/test.e2e-spec.ts:
import { noResults } from 'e2e/src/no-results';
This my export in e2e/src/noResults.ts
export const noResults = () => {...}
This is my 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'
]
}
Upvotes: 0
Views: 338
Reputation: 1841
Your module and fixture files resides in the same directory. Hence import statement can be changes as following.
import { noResults } from 'no-results';
Upvotes: 1