-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initializing Cypress v10 on a "type": "module" project with TypeScript results in an [ERR_UNKNOWN_FILE_EXTENSION]
error
#22096
Comments
@brianjenkins94 Thanks for opening the issue, seems like we have a few issues around esm and `"type": "module". @lmiller1990 has been digging into this, see #22074. It explains the technical problems we are facing with ESM. I think we'll be able to knock out many of these similar issues at once. |
[ERR_UNKNOWN_FILE_EXTENSION]
error[ERR_UNKNOWN_FILE_EXTENSION]
error
[ERR_UNKNOWN_FILE_EXTENSION]
error[ERR_UNKNOWN_FILE_EXTENSION]
error
I got your project to work locally with https://github.com/cypress-io/cypress/pull/22118/files and changing Once https://github.com/cypress-io/cypress/pull/22118/files lands, we should be good. I'm working on getting it green now. |
Hello - how's this looking? I had this working fine on our project yesterday on 10.0.2 - then updated to 10.0.3 and it also briefly worked - now I'm seeing the issue though. I probably updated Node or something in that time... |
Thanks for your work on this @lmiller1990 ! :) |
Yeah, fantastic! Thanks very much @lmiller1990 |
@lmiller1990 hm, just upgraded to
import { defineConfig } from 'cypress';
import * as users from '../database/queries/users';
export default defineConfig({
e2e: {
setupNodeEvents(on) {
on('task', {
async deleteUserByEmail(email: string) {
return (await users.deleteUserByEmail(email)) || null;
},
});
},
},
});
import { sql } from '../util/connect.js';
export async function deleteUserByEmail(email: string) {
if (!email) return undefined;
const [user] = await sql<[User | undefined]>`
DELETE FROM
users
WHERE
email = ${email}
RETURNING *
`;
return user;
} I'm thinking Or should I be using fully-specified paths also in Maybe this issue should be reopened? |
Ok I tried changing my import { defineConfig } from 'cypress';
-import * as users from '../database/queries/users';
+import * as users from '../database/queries/users.js';
export default defineConfig({
e2e: {
setupNodeEvents(on) {
on('task', {
async deleteUserByEmail(email: string) {
return (await users.deleteUserByEmail(email)) || null;
},
});
},
},
}); This results in a new error, that it cannot find the file specified (although it should be able to resolve this file -
|
Actually, I realize that I created an issue in the |
Oh, I didn't have Just tried this out, and fully-specified ESM imports work in TS now! 🎉🚀 I'll go ahead and close #20580 too! |
Great to hear your project working with native ESM - the module system we all deserve and finally have. I too look forward to living the native ESM dream one day. |
Current 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:
package.json
dependenciestsconfig.json
fileI 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
{ "type": "module" }
to thepackage.json
next.config.js
to use ESM (just changemodule.exports
toexport default
)npm install cypress@10.0.2
npx cypress open
Cypress Version
v10.0.2
Other
Originally I had this issue:
After the release of 10.0.2, I have this issue:
This issue is closely related to this issue, but I'm adding Cypress to a new project rather than doing an upgrade.
The text was updated successfully, but these errors were encountered: