question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TestCafe can't compile TypeScript test files if tsconfig.json contains the `moduleResolution` option

See original GitHub issue

What 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:

  1. Go to my website …
  2. Execute this command…
  3. 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:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
screendrivercommented, Jul 3, 2019

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?

3reactions
AndreyBelymcommented, Jul 3, 2019

Thank you for your reports, we will fix this and provide a patch release ASAP.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found