TestCafe can't compile TypeScript test files if tsconfig.json contains the `moduleResolution` option
See original GitHub issueWhat is your Test Scenario?
I upgraded from v1.2.1
to v1.3.0
in one of my TypeScript projects. Since the update I get compiler errors as you can see below. I already saw in the docs that I cannot override the module and target options. But these are defined in my existing tsconfig.json
and I don’t want to change them.
What is the Current behavior?
TestCafe complains with
You cannot override the "target" compiler option in the TypeScript configuration file.
You cannot override the "module" compiler option in the TypeScript configuration file.
ERROR Cannot prepare tests due to an error.
Error: Debug Failure. Unexpected moduleResolution: node
What is the Expected behavior?
Should not fail with errors as before with v1.2.1
What is your web application and your TestCafe test code?
This is my tsconfig.json
:
{
"compilerOptions": {
"target": "es2018",
"module": "esnext",
"outDir": "target",
"moduleResolution": "node",
"jsx": "react",
"noEmitOnError": true,
"importHelpers": true,
"sourceMap": true,
"declaration": true,
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"incremental": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"plugins": [{ "name": "typescript-tslint-plugin" }],
"typeRoots": ["./typings", "./node_modules/@types"]
},
"include": ["src/**/*", "test/**/*"],
"exclude": ["node_modules"]
}
Steps to Reproduce:
- Go to my website …
- Execute this command…
- See the error…
Your Environment details:
- testcafe version: 1.3.0
- node.js version: 12.4.0
- command-line arguments:
- browser name and version:
- platform and version:
- other:
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:10 (1 by maintainers)
Top Results From Across the Web
Typescript always errors when importing a config.json file
So it seems to me that your options are: Compile the TypeScript code yourself with your own tsconfig.json that includes the resolveJsonModule ...
Read more >Configuration File | API | Docs - TestCafe
Configuration File. When you launch TestCafe from the command line, you can specify launch options, like so: testcafe all tests/sample-fixture.js -q .
Read more >Cannot find module 'X' Error in TypeScript | bobbyhadz
To solve the error, make sure to install the module and try setting moduleResolution to node in your tsconfig.json file. If the module...
Read more >Playwright End To End Testing Tutorial: A Complete Guide
This Playwright end to end testing tutorial would guide you through its setup just in case you are wondering how to start working...
Read more >Microsoft/TypeScript - Gitter
Does having an IDE-tsconfig also work if I have multiple module/repos in my ... seems to build it's own index, it generally jumps...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
But does that mean we can’t use TestCafe out of the box (without a dedicated
tsconfig.testcafe.json
) as long as my projecttsconfig.json
defines themoduleResolution
property?Thank you for your reports, we will fix this and provide a patch release ASAP.