Skip to content
This repository was archived by the owner on Mar 5, 2022. It is now read-only.

Commit 393b273

Browse files
committed
add example with custom webpack.config file, closes #161
1 parent 1a4582f commit 393b273

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ Spec | Description
115115
[use-lodash-fp](cypress/component/basic/use-lodash-fp) | Imports and tests methods from `lodash/fp` dependency
116116
[document-spec](cypress/component/basic/document) | Checks `document` dimensions from the component
117117
[styled-components](cypress/component/basic/styled-components) | Test components that use [styled-components](https://www.styled-components.com/)
118-
[test-custom-error-boundary](https://github.com/bahmutov/test-custom-error-boundary) | Play with a component that implements error boundary
119118
<!-- prettier-ignore-end -->
120119

121120
plus a few smaller sanity specs in [cypress/component/basic](cypress/component/basic) folder.
@@ -166,6 +165,8 @@ Repo | Description
166165
[react-loading-skeleton](https://github.com/bahmutov/react-loading-skeleton) | One to one Storybook tests for React skeleton components. Uses local `.babelrc` settings without Webpack config
167166
[test-swr](https://github.com/bahmutov/test-swr) | Component test for [Zeit SWR](https://github.com/zeit/swr) hooks for remote data fetching
168167
[emoji-search](https://github.com/bahmutov/emoji-search) | Quick component test for a fork of emoji-search
168+
[test-custom-error-boundary](https://github.com/bahmutov/test-custom-error-boundary) | Play with a component that implements error boundary
169+
[Jscrambler-Webpack-React](https://github.com/bahmutov/Jscrambler-Webpack-React) | Example project with its own Webpack config file
169170
<!-- prettier-ignore-end -->
170171

171172
To find more examples, see GitHub topic [cypress-react-unit-test-example](https://github.com/topics/cypress-react-unit-test-example)

docs/recipes.md

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,28 +31,21 @@ See example repo [bahmutov/try-cra-with-unit-test](https://github.com/bahmutov/t
3131

3232
## Your webpack config
3333

34-
If you have your own webpack config, you can use included plugins file to load it.
34+
If you have your own webpack config, you can use included plugins file to load it. You can pass the webpack config file name (with respect to the root folder where `cypress.json` file sits) via plugins file or via an `env` variable in `cypress.json`
3535

3636
```js
3737
// cypress/plugins/index.js
3838
module.exports = (on, config) => {
39+
// from the root of the project (folder with cypress.json file)
40+
config.env.webpackFilename = 'webpack.config.js'
3941
require('cypress-react-unit-test/plugins/load-webpack')(on, config)
4042
// IMPORTANT to return the config object
4143
// with the any changed environment variables
4244
return config
4345
}
4446
```
4547

46-
Pass the name of the config file via `env` variable in the `cypress.json` file
47-
48-
```json
49-
{
50-
"experimentalComponentTesting": true,
51-
"env": {
52-
"webpackFilename": "demo/config/webpack.dev.js"
53-
}
54-
}
55-
```
48+
See example in [bahmutov/Jscrambler-Webpack-React](https://github.com/bahmutov/Jscrambler-Webpack-React).
5649

5750
## Your `.babelrc` file
5851

0 commit comments

Comments
 (0)