haim-io / cypress-image-diff

Visual regression test with cypress
MIT License
251 stars 62 forks source link

User config error `cypress-image-diff.config.js` #203

Closed luk82 closed 9 months ago

luk82 commented 9 months ago

Per docs user config should be called cypress-image-diff.config.js. However user config doesn't seem to apply. Looking at config.js code file is treated as module: https://github.com/uktrade/cypress-image-diff/blob/main/src/config.js#L13 Quick fix is to rename user config file as .cjs to cypress-image-diff.config.cjs

Error logged in config.js file:

cypress-image-diff.config.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 cypress-image-diff.config.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 /Projects/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead).