Initializing Cypress v10 on a "type": "module" project with TypeScript results in an `[ERR_UNKNOWN_FILE_EXTENSION]` error
See original GitHub issueCurrent behavior
Initializing Cypress v10 on a new Next.js + TypeScript project results in an [ERR_UNKNOWN_FILE_EXTENSION]
error.
As far as I can tell, this issue doesn’t appear to be:
- Specific to the OS
- Specific to the contents of the
package.json
dependencies - Specific to the contents of the
tsconfig.json
file
I tried changing all 3 but it didn’t appear to have an impact, I still get the [ERR_UNKNOWN_FILE_EXTENSION]
error.
Desired behavior
Set up E2E testing in a TypeScript project in a way where this error doesn’t occur.
Test code to reproduce
npx create-next-app@latest foobar --ts
- Add
{ "type": "module" }
to thepackage.json
- Change
next.config.js
to use ESM (just changemodule.exports
toexport default
) npm install cypress@10.0.2
npx cypress open
- Choose “E2E Testing”
- Scroll down, click “Continue”
- Error!
Cypress Version
v10.0.2
Other
Originally I had this issue:
Error [ERR_REQUIRE_ESM]: require() of ES Module cypress.config.js
After the release of 10.0.2, I have this issue:
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for cypress.config.ts
This issue is closely related to this issue, but I’m adding Cypress to a new project rather than doing an upgrade.
Issue Analytics
- State:
- Created a year ago
- Reactions:5
- Comments:11 (8 by maintainers)
Top Results From Across the Web
TypeScript - Cypress Documentation
Cypress ships with official type declarations for TypeScript. This allows you to write your tests in TypeScript. Install TypeScript To use TypeScript.
Read more >unknown file extension ".ts" for cypress.config.ts - You.com
Can't run my Node.js Typescript project TypeError ... If you don't want to remove "type": "module" (for example if you're using import statements...
Read more >Cypress Module Problem - Gleb Bahmutov
It seems if the application has type: module setting in its package.json , the Cypress plugins that runs in Node and tries to...
Read more >Cypress and Typescript - your configFile is invalid: config.ts
I am trying to setup a custom take in Cypress and am running into a Cypress config error whenever I import a Typescript...
Read more >Cypress and Typescript E2E Automation Testing - DZone
Step by Step Guide to Configure/Setup Cypress Typescript Automation Framework · Step 1: Create a Project Folder · Step 2: Open Project Folder ......
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 FreeTop 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
Top GitHub Comments
@lmiller1990 hm, just upgraded to
10.1.0
, which apparently has the ESM fix, but still getting the extension error when trying to import code which uses fully-specified imports in TS:cypress.config.ts
(excerpt)database/queries/users.ts
(excerpt)I’m thinking
ts-node
is still not configured properly for this first line indatabase/queries/users.ts
(fully-specified import path with TypeScript).Or should I be using fully-specified paths also in
cypress.config.ts
? I’ll give this a shot too…Maybe this issue should be reopened?
Hi @Abcmsaj! This is about to go green on CI: https://github.com/cypress-io/cypress/pull/22118
We will do a patch release, like in the next day or two, and it should be good 👌 please wait a bit!