Closed jclohmann closed 3 years ago
When I upgraded from Cypress 4.8.0 to 5.1.0, the crypto.randomBytes is not a function
error started occurring in cypress-plugin-snapshots/src/config.js.
I was able to fix it by adding this to cypress/plugins/index.js:
const browserify = require('@cypress/browserify-preprocessor')
module.exports = (on) => {
on('file:preprocessor', browserify())
}
https://github.com/cypress-io/cypress-browserify-preprocessor#usage
@egrubbs Thanks so much for that, that fixed it for me.
To add some context, it looks like cypress-plugin-snapshots
is using the Node crypto
package. It seems like somewhere in Cypress v5+ it no longer automatically compiling node modules for whatever reason.
Also, if you're using typescript, the above snippet will need to be:
// cypress/plugins/index.js
module.exports = (on, config) => {
on(
'file:preprocessor',
browserify({
typescript: require.resolve('typescript'),
})
);
return config;
};
Describe the bug After updating to cypress 5.0.0, I get this error-message when running a test:
Desktop (please complete the following information):
Additional context