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

Commit 726be3a

Browse files
committed
feat: add automatic code instrumentation, close #132
1 parent 93c8615 commit 726be3a

File tree

6 files changed

+238
-60
lines changed

6 files changed

+238
-60
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,20 @@ If your React and React DOM libraries are installed in non-standard paths (think
146146

147147
How can we use features that require transpilation? By using [@cypress/webpack-preprocessor](https://github.com/cypress-io/cypress-webpack-preprocessor#readme) - see the plugin configuration in [cypress/plugins/index.js](cypress/plugins/index.js)
148148

149+
## Code coverage
150+
151+
If you are using [plugins/cra-v3](plugins/cra-v3) it instruments the code on the fly using `babel-plugin-istanbul`. If you want to disable the instrumentation, use `--env coverage=false` or `CYPRESS_coverage=false` or set in your `cypress.json` file
152+
153+
```json
154+
{
155+
"env": {
156+
"coverage": false
157+
}
158+
}
159+
```
160+
161+
Works really well with coverage reporting done by plugin [cypress-io/code-coverage](https://github.com/cypress-io/code-coverage).
162+
149163
### Create React App users
150164

151165
If you are using Create-React-App v3 or `react-scripts`, and want to reuse the built in webpack before ejecting, this module ships with Cypress preprocessor in [plugins](plugins) folder. From the `cypress.json` point at the shipped plugin in the `node_modules`.

cypress/plugins/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ const options = {
2626
watchOptions: {}
2727
}
2828

29-
module.exports = on => {
29+
module.exports = (on) => {
3030
on('file:preprocessor', webpack(options))
3131
}

package-lock.json

Lines changed: 133 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
},
6565
"dependencies": {
6666
"@cypress/webpack-preprocessor": "4.1.3",
67+
"babel-plugin-istanbul": "6.0.0",
6768
"debug": "4.1.1",
6869
"find-yarn-workspace-root": "1.2.1"
6970
},

0 commit comments

Comments
 (0)