Skip to content

Commit 0ca590a

Browse files
committed
explain how to include all files
1 parent 610d0b5 commit 0ca590a

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

README.md

+17
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,23 @@ TypeScript source files should be automatically included in the report, if they
275275

276276
See [examples/ts-example](examples/ts-example), [bahmutov/cra-ts-code-coverage-example](https://github.com/bahmutov/cra-ts-code-coverage-example) or [bahmutov/cypress-angular-coverage-example](https://github.com/bahmutov/cypress-angular-coverage-example).
277277

278+
## Include code
279+
280+
By default, the code coverage report includes _only_ the instrumented files loaded by the application during the tests. If some modules are loaded dynamically, or are loaded by the pages NOT visited during any tests, these files are not going to be in the report - because the plugin does not know about them. You can include all expected source files in the report by using `include` list in the `package.json` file. The files without counters will have 0 percent code coverage.
281+
282+
For example, if you want to make sure the final report includes all JS files from the "src/pages" folder, set the "nyc" object in your `package.json` file.
283+
284+
```json
285+
{
286+
"nyc": {
287+
"all": true,
288+
"include": "src/pages/*.js"
289+
}
290+
}
291+
```
292+
293+
See example [examples/all-files](./examples/all-files)
294+
278295
## Exclude code
279296

280297
You can exclude parts of the code or entire files from the code coverage report. See [Istanbul guide](https://github.com/gotwarlost/istanbul/blob/master/ignoring-code-for-coverage.md). Common cases:

0 commit comments

Comments
 (0)