cypress: Error message printed to the console: Couldn't find tsconfig.json. tsconfig-paths will be skipped

Current behavior

Similar issue as this but with version 10.1.0 Using a tsconfig.json in the cypress directory according to the documentation Run the command npx cypress open The output displays: Couldn't find tsconfig.json. tsconfig-paths will be skipped

Moving tsconfig.json to the root of the project helped but then another error was printed:

Missing baseUrl in compilerOptions. tsconfig-paths will be skipped

Adding "baseUrl": "./", to the compilerOptions made error disappear but not sure what is this baseUrl since documentation says baseUrl should be placed in cypress.config.ts

Desired behavior

No such error printed to the console.

Test code to reproduce

mkdir sample-project
cd sample-project
npm init --force
npm i --save-dev cypress typescript
npx cypress open --e2e --browser chrome
click continue button
quit cypress runner
cd cypress
touch tsconfig.json // paste contents in this file
cd ../
npx cypress open

contents of tsconfig.json:

{
  "compilerOptions": {
    "target": "es5",
    "lib": ["es5", "dom"],
    "types": ["cypress", "node"]
  },
  "include": ["**/*.ts"]
}

Logs:

❯ mkdir sample-project
❯ cd sample-project
❯ npm init --force
npm WARN using --force Recommended protections disabled.
Wrote to /Users/piotrtarczon/VSCprojects/sample-project/package.json:

{
  "name": "sample-project",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}


❯ npm i --save-dev cypress typescript

added 166 packages, and audited 167 packages in 1s

27 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
❯ npx cypress open --e2e --browser chrome
objc[34125]: Class WebSwapCGLLayer is implemented in both /System/Library/Frameworks/WebKit.framework/Versions/A/Frameworks/WebCore.framework/Versions/A/Frameworks/libANGLE-shared.dylib (0x7ffa4ead6318) and /Users/piotrtarczon/Library/Caches/Cypress/10.1.0/Cypress.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Libraries/libGLESv2.dylib (0x111c759c8). One of the two will be used. Which one is undefined.
Couldn't find tsconfig.json. tsconfig-paths will be skipped
GET /__/ 200 7.732 ms - -
GET /__/assets/index.0128a075.css 200 5.049 ms - -
GET /__/assets/index.a96bfe29.js 200 70.632 ms - -
GET /chrome-variations/seed?osname=mac&channel=stable&milestone=102 304 673.540 ms - -
POST /ListAccounts?gpsia=1&source=ChromiumBrowser&json=standard 200 690.160 ms - -
GET /__cypress/runner/cypress_runner.css 200 3.085 ms - -
GET /__cypress/runner/cypress_runner.js 200 5.155 ms - -
GET /__/assets/Specs.ec514639.js 200 1.491 ms - 479
GET /__/assets/Index.8f76e9d7.css 200 4.905 ms - -
GET /__/assets/add-large_x16.34ef0540.js 200 7.495 ms - 753
GET /__/assets/Index.2108bd02.js 200 6.425 ms - -
GET /__/assets/SpecPatterns.5862fb95.js 200 9.320 ms - -
GET /__/assets/warning_x16.d9896e59.js 200 25.384 ms - -
GET /__/assets/CreateSpecModal.7b82dc44.js 200 15.439 ms - -
GET /__/assets/settings_x16.2429c71a.js 200 27.289 ms - -
GET /__/assets/cypress_s.29af549a.png 200 7.971 ms - 4425
GET /__/assets/chrome.1b5cb774.svg 200 1.342 ms - -
GET /__/assets/electron.fb07f5cc.svg 200 1.916 ms - -
GET /__/assets/firefox.9be61e66.svg 200 2.545 ms - -
GET /__cypress/runner/favicon.ico?v2 404 0.973 ms - 136
GET /__cypress/assets/favicon.png?v2 404 1.132 ms - 136
POST /v1:GetModels?key=AIzaSyBOti4mM-6x9WDnZIjIeyEU21OpBXqWBgw 200 766.750 ms - -
❯ cd cypress
❯ touch tsconfig.json
❯ cd ../
❯ npx cypress open
objc[34991]: Class WebSwapCGLLayer is implemented in both /System/Library/Frameworks/WebKit.framework/Versions/A/Frameworks/WebCore.framework/Versions/A/Frameworks/libANGLE-shared.dylib (0x7ffa4ead6318) and /Users/piotrtarczon/Library/Caches/Cypress/10.1.0/Cypress.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Libraries/libGLESv2.dylib (0x1124469c8). One of the two will be used. Which one is undefined.
Couldn't find tsconfig.json. tsconfig-paths will be skipped

Cypress Version

10.1.10

Other

No response

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 14
  • Comments: 36 (11 by maintainers)

Commits related to this issue

Most upvoted comments

Why CY makes mandatory this tsconfig.json?. We do not use TS in some of our projects and CY keeps complaining about such file!

Adding “baseUrl”: “./”, to the compilerOptions made error disappear

This only seems to apply if tsconfig.json is in the root, as opposed to the Cypress folder.

If I put tsconfig.json in the Cypress folder (like Rachel’s example and like the docs specify) then it seems to be ignored. Commenting or adding baseUrl has no effect on the error message.

If I put tsconfig.json in the root, then the error is suppressed. If I comment out my baseUrl declaration while tsconfig.json is in the root, I get the following:

Missing baseUrl in compilerOptions. tsconfig-paths will be skipped

Has Cypress 10 changed the expected location of tsconfig.json?

This issue covers two topics:

  1. When TS is installed but no tsconfig.json is present, it logs Couldn't find tsconfig.json. tsconfig-paths will be skipped. #21805 is requesting that log be suppressed since nothing is necessarily wrong
  2. When TS is installed and tsconfig.json is added to the cypress root in accordance with the documentation, it logs Couldn't find tsconfig.json. tsconfig-paths will be skipped

I’ve created a repo here to reproduce the issue

@ptarczon thank you for reporting this issue!

To answer this question…

Adding “baseUrl”: “./”, to the compilerOptions made error disappear but not sure what is this baseUrl since documentation says baseUrl should be placed in cypress.config.ts

Both TypeScript and Cypress have a property called baseUrl in their respective config files, but they’re different concepts 😸

Cypress baseUrl: “URL used as prefix for cy.visit() or cy.request() command’s URL.”

TypeScript baseUrl: “Lets you set a base directory to resolve non-absolute module names.”

This is bad experience when I’m following the cookbook and facing this error. Please fix either the documentation or the code.

I’m not sure if i’m doing this right but using @rachelruderman post:

@ptarczon thank you for reporting this issue!

To answer this question…

Adding “baseUrl”: “./”, to the compilerOptions made error disappear but not sure what is this baseUrl since documentation says baseUrl should be placed in cypress.config.ts

Both TypeScript and Cypress have a property called baseUrl in their respective config files, but they’re different concepts 😸

Cypress baseUrl: “URL used as prefix for cy.visit() or cy.request() command’s URL.”

TypeScript baseUrl: “Lets you set a base directory to resolve non-absolute module names.”

I have 2 tsconfig.json files. One in the root of my project and one in the /cypress folder. I added baseUrl to the one in the root folder and the error goes away. the tsconfig.json in the cypress folder is just as the documentation said it should be:

/tsconfig.json

{
  "extends": "expo/tsconfig.base",
  "compilerOptions": {
    "strict": true,
    "baseUrl": "."
  }
}

/cypress/tsconfig.json

{
  "compilerOptions": {
    "target": "es5",
    "lib": ["es5", "dom"],
    "types": ["cypress", "node"],
  },
  "include": ["**/*.ts"]
}

Hope This helps someone

This is still happening in 12.12.0 my tsconfig.json file is in my cypress folder. I am getting "Unresolved function or method describe() " in all my cypress tests. And i get this too in the pipeline: Couldn’t find tsconfig.json. tsconfig-paths will be skipped Any solution so far for this apart placing the tsconfig.json in the root of the project

It’s a limitation of an old version of tsconfig-paths. It is no longer needed in >4 should cypress finally update.

This error message is confusing. It’s not clear what the implication is. My test seems to run fine.

Also encountered. Why not fix it? It’s been open since June 2022 and still getting attention

I am seeing the warning message “Couldn’t find tsconfig.json. tsconfig-paths will be skipped” on Cypress 10.7.0 after running npm install cypress@10.7.0 from a project which was previously running Cypress 9.7.0. The Cypress test specs are purely JavaScript. There are no *.ts files in the Cypress folders.

On the first run of npx cypress open on Cypress 10.7.0 the warning message “Couldn’t find tsconfig.json. tsconfig-paths will be skipped” is displayed, before any Cypress 10 migration steps in the Cypress console have been carried out.

npx cypress open run with Cypress 9.7.0 does not output this message. I did however confirm that npx cypress open run with Cypress 10.0.0 also produces the warning message.

The warning message does not seem to affect the successful running of E2E tests written in JavaScript (*.js).

The problem is reproducible on Windows 10 and Windows 11 with Cypress 10.7.0. On Ubuntu 20.04 / 22.04 I could only reproduce with Cypress 10.0.0, not with Cypress 10.11.0.

4.0.0+ but 4.1.0 fixed some bugs. They published a changelog.