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

(bug) cypress-plugin-snapshots errors out in component testing #197

Open
rhobot opened this issue Jul 22, 2021 · 2 comments
Open

(bug) cypress-plugin-snapshots errors out in component testing #197

rhobot opened this issue Jul 22, 2021 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@rhobot
Copy link

rhobot commented Jul 22, 2021

Describe the bug

Once cypress-plugin-snapshots/commands is imported in cypress/support/index.js, running component tests (i.e. npx cypress open-ct errors out with Cannot find module 'crypto'.

Note that I'm not trying to run cypress-plugin-snapshots in component testing. It just happens to error out.

To Reproduce
Steps to reproduce the behavior:

  1. Set up Cypress component testing
  2. Add some example component tests
  3. Run npx cypress open-ct
  4. Click a spec file
  5. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots

nebula

Desktop (please complete the following information):

  • OS: OSX
  • Cypress Version 8.0.0.
  • Used webpack for setting up Cypress component testing.

Additional context

I've attempted to fix the error by adding fallbacks in webpack.
I eventually had to add fallbacks of crypto, path, and stream.
After that it still complains that process is not defined.

I also searched for disabling cypress-plugin-snapshots only in component testing but I couldn't find a way.
The commands are always executed in both integration testing and component testing.

@rhobot rhobot added the bug Something isn't working label Jul 22, 2021
@alikirec
Copy link

alikirec commented Aug 4, 2021

That's a problem that I ran into when I tried to use webpack (v5) dev configuration.
I added buffer package to dev dependencies, then added buffer package in webpack config like following

  plugins: [
    ....
    new webpack.ProvidePlugin({
      process: 'process/browser',
      Buffer: ['buffer', 'Buffer'],
    }),
    ...
  ],
  ...
  node: {
    global: true,
  }

if you don't want to change your dev config, you can use env variables and run component tests like IS_CT=true npx cypress open-ct

@talcodota
Copy link

talcodota commented Apr 17, 2022

nothing worked for me (running on vite.js), so I've overridden the supportFile location path only for component tests, where I did not import cypress-plugin-snapshots/commands

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

4 participants