Skip to content

Commit 20b87e3

Browse files
committed
add section on app vs unit test instrumentation
1 parent aa73841 commit 20b87e3

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Diff for: README.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ module.exports = (on, config) => {
2727
}
2828
```
2929

30-
### Instrument your application
30+
## Instrument your application
3131

3232
This plugin **DOES NOT** instrument your code. You have to instrument it yourself using [Istanbul.js](https://istanbul.js.org/) tool. Luckily it is not difficult. For example, if you are already using Babel to transpile you can add [babel-plugin-istanbul](https://github.com/istanbuljs/babel-plugin-istanbul) to your `.babelrc` and instrument on the fly.
3333

@@ -53,6 +53,12 @@ If you have instrumented your application's code and see the `window.__coverage_
5353

5454
That should be it!
5555

56+
### App vs unit tests
57+
58+
You need to instrument your web application. This means that when the test does `cy.visit('localhost:3000')` any code the `index.html` requests should be instrumented by YOU. See [Examples](#examples) section for advice, usually you need to stick `babel-plugin-istanbul` into your pipeline somewhere.
59+
60+
If you are testing individual functions from your application code by importing them directly into Cypress spec files, this is called "unit tests" and Cypress can instrument this scenario for you. See [Instrument unit tests](#instrument-unit-tests) section.
61+
5662
## Reports
5763

5864
The `coverage` folder has results in several formats, and the coverage raw data is stored in `.nyc_output` folder. You can see the coverage numbers yourself. This plugin has `nyc` as a dependency, so it should be available right away. Here are common examples:
@@ -117,7 +123,7 @@ module.exports = (on, config) => {
117123

118124
Now the code coverage from spec files will be combined with end-to-end coverage.
119125

120-
### Alternative
126+
### Alternative for unit tests
121127

122128
If you cannot use `.babelrc` for some reason (maybe it is used by other tools?), try using the Browserify transformer included with this module in `use-browserify-istanbul` file.
123129

0 commit comments

Comments
 (0)