haim-io / cypress-image-diff

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

Error: ERR_PACKAGE_PATH_NOT_EXPORTED #210

Closed nikitalepikhin-ext54869 closed 2 months ago

nikitalepikhin-ext54869 commented 4 months ago

I have set cypress component tests up for a React TS application in a NX monorepo. The contents of the cypress.config.ts file are the following:

import { defineConfig } from 'cypress';
import { nxComponentTestingPreset } from '@nx/react/plugins/component-testing';
import getCompareSnapshotsPlugin from 'cypress-image-diff-js/types/plugin';

export default defineConfig({
  component: {
    ...nxComponentTestingPreset(__filename, {
      bundler: 'webpack',
    }),
    setupNodeEvents(on, config) {
      return getCompareSnapshotsPlugin(on, config);
    },
  },
});

Upon launching cypress tests, I am getting the following error: Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './types/plugin' is not defined by "exports" in /Users/myUsername/.../node_modules/cypress-image-diff-js/package.json.

These are the versions of packages from package.json:

"cypress": "12.2.0",
"cypress-image-diff-html-report": "2.0.2",
"cypress-image-diff-js": "2.1.3",

What could be causing this issue here? Thank you.

timduffin commented 4 months ago

Per docs, should import getCompareSnapshotsPlugin from 'cypress-image-diff-js/types/plugin'; not be

import getCompareSnapshotsPlugin from 'cypress-image-diff-js/plugin';
github-actions[bot] commented 3 months ago

This issue is stale because it has been open for 30 days with no activity.

vijaycapsifi commented 3 months ago

Even with import getCompareSnapshotsPlugin from 'cypress-image-diff-js/types/plugin'; there is an error

TS2307: Cannot find module 'cypress-image-diff-js/plugin' or its corresponding type declarations.

kien-ht commented 2 months ago

@vijaycapsifi As Timduffin suggested above, it should be:

import getCompareSnapshotsPlugin from 'cypress-image-diff-js/plugin';

Please refer to our documentation for further details