Skip to content

Commit 11a2163

Browse files
committed
update readme
1 parent f9e54eb commit 11a2163

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

README.md

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ Register tasks in your `cypress/plugins/index.js` file
2323

2424
```js
2525
module.exports = (on, config) => {
26-
on('task', require('@cypress/code-coverage/task'))
26+
require('@cypress/code-coverage/task')(on, config)
27+
// IMPORTANT to return the config object
28+
// with the any changed environment variables
29+
return config
2730
}
2831
```
2932

@@ -109,8 +112,9 @@ Put the following in `cypress/plugins/index.js` file to use `.babelrc` file
109112

110113
```js
111114
module.exports = (on, config) => {
112-
on('task', require('@cypress/code-coverage/task'))
115+
require('@cypress/code-coverage/task')(on, config)
113116
on('file:preprocessor', require('@cypress/code-coverage/use-babelrc'))
117+
return config
114118
}
115119
```
116120

@@ -122,11 +126,12 @@ If you cannot use `.babelrc` for some reason (maybe it is used by other tools?),
122126

123127
```js
124128
module.exports = (on, config) => {
125-
on('task', require('@cypress/code-coverage/task'))
129+
require('@cypress/code-coverage/task')(on, config)
126130
on(
127131
'file:preprocessor',
128132
require('@cypress/code-coverage/use-browserify-istanbul')
129133
)
134+
return config
130135
}
131136
```
132137

@@ -349,6 +354,26 @@ npm run dev:no:coverage
349354
- [bahmutov/code-coverage-subfolder-example](https://github.com/bahmutov/code-coverage-subfolder-example) shows how to instrument `app` folder using `nyc instrument` as a separate step before running E2E tests
350355
- [bahmutov/docker-with-cypress-included-code-coverage-example](https://github.com/bahmutov/docker-with-cypress-included-code-coverage-example) runs tests inside pre-installed Cypress using [cypress/included:x.y.z](https://github.com/cypress-io/cypress-docker-images/tree/master/included) Docker image and reports code coverage.
351356

357+
## Migrations
358+
359+
### v2 to v3
360+
361+
Change the plugins file `cypress/plugins/index.js`
362+
363+
```js
364+
// BEFORE
365+
module.exports = (on, config) => {
366+
on('task', require('@cypress/code-coverage/task'))
367+
}
368+
// AFTER
369+
module.exports = (on, config) => {
370+
require('@cypress/code-coverage/task')(on, config)
371+
// IMPORTANT to return the config object
372+
// with the any changed environment variables
373+
return config
374+
}
375+
```
376+
352377
## Debugging
353378

354379
This plugin uses [debug](https://github.com/visionmedia/debug) module to output additional logging messages from its [task.js](task.js) file. This can help with debugging errors while saving code coverage or reporting. In order to see these messages, run Cypress from the terminal with environment variable `DEBUG=code-coverage`. Example using Unix syntax to set the variable:

0 commit comments

Comments
 (0)