diff --git a/examples/webpack-options/.npmrc b/examples/webpack-options/.npmrc
new file mode 100644
index 00000000..43c97e71
--- /dev/null
+++ b/examples/webpack-options/.npmrc
@@ -0,0 +1 @@
+package-lock=false
diff --git a/examples/webpack-options/cypress.json b/examples/webpack-options/cypress.json
new file mode 100644
index 00000000..00824cab
--- /dev/null
+++ b/examples/webpack-options/cypress.json
@@ -0,0 +1,7 @@
+{
+ "fixturesFolder": false,
+ "testFiles": "**/*cy-spec.js",
+ "viewportWidth": 500,
+ "viewportHeight": 500,
+ "experimentalComponentTesting": true
+}
diff --git a/examples/webpack-options/cypress/component/Test.cy-spec.js b/examples/webpack-options/cypress/component/Test.cy-spec.js
new file mode 100644
index 00000000..30f4e451
--- /dev/null
+++ b/examples/webpack-options/cypress/component/Test.cy-spec.js
@@ -0,0 +1,9 @@
+import React from 'react'
+import { mount } from 'cypress-react-unit-test'
+
+describe('components', () => {
+ it('works', () => {
+ mount(
Text
)
+ cy.contains('Text')
+ })
+})
diff --git a/examples/webpack-options/cypress/integration/cy-spec.js b/examples/webpack-options/cypress/integration/cy-spec.js
new file mode 100644
index 00000000..d815fd54
--- /dev/null
+++ b/examples/webpack-options/cypress/integration/cy-spec.js
@@ -0,0 +1,6 @@
+///
+describe('integration spec', () => {
+ it('works', () => {
+ expect(1).to.equal(1)
+ })
+})
diff --git a/examples/webpack-options/cypress/plugins/index.js b/examples/webpack-options/cypress/plugins/index.js
new file mode 100644
index 00000000..43cb056e
--- /dev/null
+++ b/examples/webpack-options/cypress/plugins/index.js
@@ -0,0 +1,9 @@
+// @ts-check
+const webpackPreprocessor = require('@cypress/webpack-preprocessor')
+module.exports = (on, config) => {
+ on(
+ 'file:preprocessor',
+ // @ts-ignore
+ webpackPreprocessor(webpackPreprocessor.defaultOptions),
+ )
+}
diff --git a/examples/webpack-options/cypress/support/index.js b/examples/webpack-options/cypress/support/index.js
new file mode 100644
index 00000000..5d9ef5d1
--- /dev/null
+++ b/examples/webpack-options/cypress/support/index.js
@@ -0,0 +1 @@
+require('cypress-react-unit-test/dist/hooks')
diff --git a/examples/webpack-options/package.json b/examples/webpack-options/package.json
new file mode 100644
index 00000000..9a31c8af
--- /dev/null
+++ b/examples/webpack-options/package.json
@@ -0,0 +1,12 @@
+{
+ "name": "example-webpack-options",
+ "description": "Using default Webpack options to transpile simple tests",
+ "private": true,
+ "scripts": {
+ "test": "../../node_modules/.bin/cypress run",
+ "cy:open": "../../node_modules/.bin/cypress open"
+ },
+ "devDependencies": {
+ "cypress-react-unit-test": "file:../.."
+ }
+}
diff --git a/plugins/cra-v3/file-preprocessor.js b/plugins/cra-v3/file-preprocessor.js
index 5f6371ce..11c14f81 100644
--- a/plugins/cra-v3/file-preprocessor.js
+++ b/plugins/cra-v3/file-preprocessor.js
@@ -4,16 +4,13 @@ const findWebpack = require('find-webpack')
const webpackPreprocessor = require('@cypress/webpack-preprocessor')
const { addImageRedirect } = require('../utils/add-image-redirect')
-const getWebpackOptions = opts => {
+const getWebpackPreprocessorOptions = opts => {
debug('top level opts %o', opts)
const webpackOptions = findWebpack.getWebpackOptions()
if (!webpackOptions) {
console.error('⚠️ Could not find Webpack options, using defaults')
- return {
- webpackOptions: webpackPreprocessor.defaultOptions,
- watchOptions: {},
- }
+ return webpackPreprocessor.defaultOptions
}
debug('webpack options: %o', webpackOptions)
findWebpack.cleanForCypress(opts, webpackOptions)
@@ -42,7 +39,7 @@ module.exports = config => {
addFolderToTranspile: config.componentFolder,
coverage: !coverageIsDisabled,
}
- const preprocessorOptions = getWebpackOptions(opts)
+ const preprocessorOptions = getWebpackPreprocessorOptions(opts)
debug('final webpack options %o', preprocessorOptions.webpackOptions)