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.
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
Should not fail with errors as before with v1.2.1
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"]
}
Following -- same issue & question, slightly diff environment.
Your Environment details:
testcafe version: 1.3.0
node.js version: 10.15.0
typescript: 3.5.2
I see the same error since yesterday's update to 1.3.0
"compilerOptions": {
"module": "esnext",
"target": "es6",
"lib": ["es2017", "dom"],
"sourceMap": true,
"allowJs": true,
"jsx": "react",
"rootDir": "src",
"baseUrl": ".",
"moduleResolution": "node",
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": false,
"strictNullChecks": true,
"suppressImplicitAnyIndexErrors": true,
"noUnusedLocals": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"paths": {
"types": []
}
Thank you for your reports, we will fix this and provide a patch release ASAP.
The warnings about overriding the target and module options do not interrupt compilation and can be ignored. However, we will try to reduce the number of conditions that can cause them.
The moduleResolution option is the problematic one. If we want to allow overriding it, we should transform the node and classic values to 2 and 1 respectively because this option has different enum types when configured from CLI/config and API. But I think that we should disable the possibility of overriding it because otherwise, you won't be able to import Selector and ClientFunction from TestCafe.
As a workaround, you can create a separate tsconfig.testcafe.json configuration file which doesn't contain the moduleResolution option and pass it to TestCafe via the tsConfigPath option from the .testcaferc.json configuration file: https://devexpress.github.io/testcafe/documentation/using-testcafe/configuration-file.html#tsconfigpath.
But I think that we should disable the possibility of overriding
But does that mean we can't use TestCafe out of the box (without a dedicated tsconfig.testcafe.json) as long as my project tsconfig.json defines the moduleResolution property?
I would prefer if the new feature _Customize Compiler Options_ required an explicit opt in like providing the command line parameter or adding it to the configuration file.
It was rather surprising for me that after the upgrade testcafe uses a tsconfig that was never intended to be used by testcafe.
@signed, try to use the [email protected] version where we have addressed this problem. 聽 If the issue still occurs,聽please describe your scenario in greater detail and what聽Customize Compiler Options break it.
I have a small sample project that is working fine with 1.2.1.
yarn start
yarn testcafe:run
Tests run as expected.
I tried [email protected]:
yarn add -D [email protected]
yarn start
yarn testcafe:run
The tests fail with the following error:
You cannot override the "module" compiler option in the TypeScript configuration file.
You cannot override the "target" compiler option in the TypeScript configuration file.
ERROR Cannot prepare tests due to an error.Error: TypeScript compilation failed.
Option 'sourceMap' cannot be specified with option 'inlineSourceMap'.at Function._reportErrors (
/sandboxes/typescript/testcafe/node_modules/testcafe/src/compiler/test-file/formats/typescript/compiler.js:38:15)
at TypeScriptTestFileCompiler._precompileCode (/sandboxes/typescript/testcafe/node_modules/testcafe/src/compiler/test-file/formats/typescript/compiler.js:79:40)
at TypeScriptTestFileCompiler._compileCodeForTestFiles (/sandboxes/typescript/testcafe/node_modules/testcafe/src/compiler/test-file/api-based.js:110:29)
at tsConfig.init.then (/sandboxes/typescript/testcafe/node_modules/testcafe/src/compiler/test-file/formats/typescript/compiler.js:53:30)
I apologize for this inconvenience. Unfortunately, our understanding of different TypeScript options wasn't deep enough. I've created a list of all options that can cause compilation problems in this issue: https://github.com/DevExpress/testcafe/issues/3983.
We decided to disable the functionality of automatically detecting and applying TypeScript configuration files - #3986. I still think that this feature can be very useful and won't cause issues if implemented properly - take a look at ts-node. But we won't try to enable it back until we fix all possible combinations of conflicting options and find a way to implement it without breaking user tests.
This thread has been automatically locked since it is closed and there has not been any recent activity. Please open a new issue for related bugs or feature requests. We recommend you ask TestCafe API, usage and configuration inquiries on StackOverflow.
Most helpful comment
But does that mean we can't use TestCafe out of the box (without a dedicated
tsconfig.testcafe.json) as long as my projecttsconfig.jsondefines themoduleResolutionproperty?