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

Commit c17f88e

Browse files
committed
change babelrc recipe to use explicit plugins file
1 parent c130dc4 commit c17f88e

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ Requires [Node](https://nodejs.org/en/) version 8 or above.
2121
npm install --save-dev cypress cypress-react-unit-test
2222
```
2323

24-
Include this plugin from your project's `cypress/support/index.js`
24+
1. Include this plugin from your project's `cypress/support/index.js`
2525

2626
```js
27-
require('cypress-react-unit-test/dist/hooks')
27+
require('cypress-react-unit-test/support')
2828
```
2929

30-
Then tell Cypress how your React application is transpiled or bundled (using Webpack), so Cypress can load your components. See [Recipes](./docs/recipes.md)
30+
2. Tell Cypress how your React application is transpiled or bundled (using Webpack), so Cypress can load your components. See [Recipes](./docs/recipes.md)
3131

32-
⚠️ Turn the experimental component support on in your `cypress.json`. You can also specify where component spec files are located. For exampled to have them located in `src` folder use:
32+
3. ⚠️ Turn the experimental component support on in your `cypress.json`. You can also specify where component spec files are located. For exampled to have them located in `src` folder use:
3333

3434
```json
3535
{

docs/recipes.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,23 @@ If you have your own webpack config, you can use included plugins file to load i
6464

6565
## Your `.babelrc` file
6666

67-
If you are using Babel without Webpack to transpile, you can use the plugin that tells Babel loader to use your configuration file. In `cypress.json` file set:
67+
If you are using Babel without Webpack to transpile, you can use the plugin that tells Babel loader to use your configuration file.
68+
69+
```js
70+
// cypress/plugins/index.js
71+
module.exports = (on, config) => {
72+
// tell Cypress to bundle specs and components using project's .babelrc file
73+
require('cypress-react-unit-test/plugins/babelrc')(on, config)
74+
// IMPORTANT to return the config object
75+
// with the any changed environment variables
76+
return config
77+
}
78+
```
79+
80+
In `cypress.json` file set:
6881

6982
```json
7083
{
71-
"pluginsFile": "node_modules/cypress-react-unit-test/plugins/babelrc",
72-
"supportFile": "node_modules/cypress-react-unit-test/support",
7384
"experimentalComponentTesting": true
7485
}
7586
```

0 commit comments

Comments
 (0)