Skip to content

Commit f00ec47

Browse files
committed
chore: explain that this plugin does not instrument code
1 parent 6c5069b commit f00ec47

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

README.md

+21-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,27 @@ module.exports = (on, config) => {
3131
}
3232
```
3333

34-
If your application is loaded Istanbul-instrumented source code, then the coverage information will be automatically saved into `.nyc_output` folder and a report will be generated after the tests finish (even in the interactive mode). Find the LCOV and HTML report in the `coverage/lcov-report` folder.
34+
### Instrument your application
35+
36+
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.
37+
38+
```
39+
{
40+
"plugins": ["istanbul"]
41+
}
42+
```
43+
44+
Please see the [Examples](#examples) section down below, you can probably find a linked project matching your situation to see how to instrument your application's source code before running end-to-end tests to get the code coverage.
45+
46+
If your application has been instrumented correctly, then you should see additional counters and instructions in the application's JavaScript resources, like the image down below shows.
47+
48+
![Instrumented code](images/instrumented-code.png)
49+
50+
You should see the `window.__coverage__` object in the "Application under test iframe"
51+
52+
![Window coverage object](images/window-coverage-object.png)
53+
54+
If you have instrumented your application's code and see the `window.__coverage__` object, then this plugin will save the coverage into `.nyc_output` folder and will generate reports after the tests finish (even in the interactive mode). Find the LCOV and HTML report in the `coverage/lcov-report` folder.
3555

3656
![Coverage report](images/coverage.jpg)
3757

images/instrumented-code.png

513 KB
Loading

images/window-coverage-object.png

378 KB
Loading

0 commit comments

Comments
 (0)