Closed ajdintbk closed 3 months ago
Check https://cypress.visual-image-diff.dev/#rename-import-path In both cases the /dist/ need to be removed from the path.
"cypress": "12.2.0",
"cypress-image-diff-html-report": "^2.0.2",
"cypress-image-diff-js": "^2.1.3"
@ajdintbk
Here it worked like this:
cypress.config.js
const { defineConfig } = require("cypress");
const getCompareSnapshotsPlugin = require('cypress-image-diff-js/plugin');
module.exports = defineConfig({
e2e: {
setupNodeEvents(on, config) {
getCompareSnapshotsPlugin (on, config)
},
},
});
commands.js
const compareSnapshotCommand = require("cypress-image-diff-js/dist/command");
compareSnapshotCommand()
This issue is stale because it has been open for 30 days with no activity.
Here is my configuration based on the latest documentation^1:
cypress.config.js
^3
const { defineConfig } = require("cypress");
const getCompareSnapshotsPlugin = require('cypress-image-diff-js/plugin'); // Remove dist path
module.exports = defineConfig({
e2e: {
setupNodeEvents(on, config) {
// implement node event listeners here
return getCompareSnapshotsPlugin(on, config);
},
},
});
cypress/support/e2e.js
^4
// Import commands.js using ES2015 syntax:
import './commands'
// Alternatively you can use CommonJS syntax:
// require('./commands')
const compareSnapshotCommand = require('cypress-image-diff-js'); // Remove dist path
compareSnapshotCommand();
I'm not configuring anything in the commands.js
file.
My package versions:
"devDependencies": {
"cypress": "^13.7.1",
"cypress-image-diff-html-report": "^2.0.2",
"cypress-image-diff-js": "^2.1.4"
},
I get errors at both places where the import is needed
Error: Webpack Compilation Error
TS2307: Cannot find module 'cypress-image-diff-js/command' or its corresponding type declarations.
and
TS2307: Cannot find module 'cypress-image-diff-js/plugin' or its corresponding type declarations.
Here is my config:
cypress-image-diff-config.ts
import { defineConfig } from 'cypress';
import getCompareSnapshotsPlugin from 'cypress-image-diff-js/plugin';
export default defineConfig({
e2e: {
setupNodeEvents(on, config) {
return getCompareSnapshotsPlugin(on, config)
}
}
})
In this line of code import getCompareSnapshotsPlugin from 'cypress-image-diff-js/plugin';
, cypress-image-diff-js/plugin
is in red in VS Code as it can't seem to resolve.
cypress/support/e2e.ts
import './commands';
import compareSnapshotCommand from 'cypress-image-diff-js/command';
compareSnapshotCommand();
In this line of code import compareSnapshotCommand from 'cypress-image-diff-js/command';
, cypress-image-diff-js/command
is in red in VS Code as it can't seem to resolve.
Package versions
"cypress": "^13.8.0",
"cypress-image-diff-html-report": "^2.0.2",
"cypress-image-diff-js": "^2.1.3",
Please note I am using Cypress Cucumber to run my tests.
I'm getting "Webpack Compilation Error Module not found" when following all the instructions.
so, it's an issue with package.json of the plugin 'cypress-image-diff':
The missing export is:
"exports": { "./dist/config.default": { "default": "./dist/config.default.js" }, ...
after it it workds
This issue is stale because it has been open for 30 days with no activity.
This issue was closed because it has been inactive for 30 days since being marked as stale.
This issue is still present in 2.2.1. Out of the box, the documented import path isn't valid.
I tried to install this package and I got error Package subpath './dist/plugin' is not defined by "exports" in/node-modules/cypress-image-diff-js/package.json.
I'm using Angular 17 and Cypress 13 and installed package by running
npm i -D cypress-image-diff-js
My cypress.config.ts looks like this:
I added this in
commands.ts
and ine2e.ts
When running npx cypress open I get Package subpath './dist/plugin' is not defined by "exports" in/node-modules/cypress-image-diff-js/package.json.
And in tests I can not say cy.compareSnapshot(...)
What am I doing wrong here?