Skip to content
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

Non-TS projects Readme Configuration does not work v5+ #244

Closed
NickStees opened this issue May 8, 2024 · 10 comments
Closed

Non-TS projects Readme Configuration does not work v5+ #244

NickStees opened this issue May 8, 2024 · 10 comments
Labels
bug Something isn't working

Comments

@NickStees
Copy link

I followed the Readme for install and configuration but something about the readme is wrong for non-typescript projects. I then figured I would install V4.x and that seemed to work, so something is wrong with the setup now for v5.

https://github.com/cypress-visual-regression/cypress-visual-regression?tab=readme-ov-file#configuration

I get the following error

It threw an error when required, check the stack trace below:

Error [ERR_REQUIRE_ESM]: require() of ES Module /node_modules/cypress-visual-regression/dist/plugin.js from /cypress.config.js not supported.
plugin.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules.
Instead either rename plugin.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in /node_modules/cypress-visual-regression/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead).
@vanessavun
Copy link

I recently started getting this same message too but my version was on v5.0.0. Upgrading to v5.0.1 didn't help.

@vanessavun
Copy link

I downgraded Cypress to v13.8.1 (with v5.0.0) and Cypress is working again.

@area73
Copy link
Collaborator

area73 commented May 8, 2024

It looks that we have some issues with ESM and commonsJS

@area73 area73 added the bug Something isn't working label May 8, 2024
@eugenet8k
Copy link
Contributor

@area73 Yeah, it's adding "type": "module" in the package.json:

811d77c#diff-7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519R5

Maybe the easier approach would be to remove type but provide both main and module attributes for different module system entrypoints.

@burkedavid
Copy link

Also getting this even tried updating type to commonjs but that just ran into problems with chalk.

Downgraded to 5.0.0 and working again

@torresrodrigoe
Copy link

seems like better solution is to downgrade to 5.0.0 right ?

@iacopo-carlini-LEI
Copy link

Downgrading to Cypress v.13.8.0 and cypress-visual-regression v.5.0.0 worked for me

@Zaista
Copy link
Collaborator

Zaista commented Jun 4, 2024

I did a bit of tinkering, removed the troubling "type": "module", added dedicated cjs and esm output files, and also added solutions to some specific cypress problems.

Now I've released an alpha version before and official release, and all the test I've done were successful, nonetheless I would appreciate it some of you tried it out to see if it really works for your setup.

So, please install the alpha version using the npm i cypress-visual-regression@5.0.2-alpha and try it out. To see appropriate configurations, you can refer to example test projects I've added, for example here

@mikeyavorsky
Copy link

I got a good test result for 5.0.2-alpha.

My config file contains const { configureVisualRegression } = require("cypress-visual-regression");

With cypress-visual-regression@5.0.1, I see "Cypress configuration error" and "Your config file is invalid" in the Cypress test runner. After running npm i -D cypress-visual-regression@5.0.2-alpha I am able to open Cypress and run specs as normal.

@Zaista
Copy link
Collaborator

Zaista commented Jun 9, 2024

This issue should be fixed with v5.0.2

@Zaista Zaista closed this as completed Jun 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

9 participants