Skip to content

Instantly share code, notes, and snippets.

@Cerberus
Created May 26, 2022 06:35
Show Gist options
  • Save Cerberus/f0dcae6899788969ec1c4304b9a904d8 to your computer and use it in GitHub Desktop.
Save Cerberus/f0dcae6899788969ec1c4304b9a904d8 to your computer and use it in GitHub Desktop.
Use Component Testing (cypress) with CRACO + ESBuild loader
// craco.config.js
const CracoEsbuildPlugin = require('craco-esbuild')
const { ProvidePlugin } = require('webpack')
module.exports = {
webpack: {
plugins: {
add: [new ProvidePlugin({ React: 'react' })],
},
},
plugins: [{ plugin: CracoEsbuildPlugin }],
}
// cypress/plugins/index.js
process.env.NODE_ENV = 'development'
const cracoConfig = require('../../craco.config.js')
const devServer = require('@cypress/react/plugins/craco')
module.exports = (on, config) => {
devServer(on, config, cracoConfig)
return config
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment