You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
nyc runs a lot of file system operations relative to the project root directory.
201
201
During startup nyc will look for the *default* project root directory.
202
202
The *default* project root directory is the first directory found that contains a `package.json` file when searching from the current working directory up.
203
-
If nyc fails to find a directory containing a `package.json` file, it will use current working directory.
203
+
If nyc fails to find a directory containing a `package.json` file, it will use current working directory as the *default* project root directory.
204
204
You can change the project root directory with the `--cwd` option.
205
205
206
206
nyc uses the project root directory when:
207
-
* looking for source files to cover
207
+
* looking for source files to instrument
208
208
* creating globs for include and exclude rules during file selection
209
209
* loading custom require hooks from the `require` array
210
210
@@ -217,34 +217,35 @@ nyc may create artefact directories within the project root, such as:
217
217
218
218
By default, nyc only collects coverage for source files that are visited during a test.
219
219
It does this by watching for files that are `require()`'d during the test.
220
+
When a file is `require()`'d, nyc creates and returns an instrumented version of the source, rather than the original.
220
221
Only source files that are visited during a test will appear in the coverage report and contribute to coverage statistics.
221
222
222
223
nyc will instrument all files if the `--all` flag is set.
223
224
In this case all files will appear in the coverage report and contribute to coverage statistics.
224
225
225
-
nyc will only collect coverage for files that are located under `cwd`, and then only `*.js` files or files with extensions listed in in the `extension` array.
226
+
nyc will only collect coverage for files that are located under `cwd`, and then only `*.js` files or files with extensions listed in the `extension` array.
226
227
227
-
You can reduce the set of covered files by adding `include` and `exclude` filter arrays to your config.
228
-
These allow you to shape the set of covered files by specifying glob patterns that can filter files from the covered set.
228
+
You can reduce the set of instrumented files by adding `include` and `exclude` filter arrays to your config.
229
+
These allow you to shape the set of instrumented files by specifying glob patterns that can filter files from the default instrumented set.
229
230
The `exclude` array may also use exclude negated glob patterns, these are specified with a `!` prefix, and can restore sub-paths of excluded paths.
230
231
231
232
Globs are matched using [minimatch](https://www.npmjs.com/package/minimatch).
232
233
233
234
We use the following process to remove files from consideration:
234
-
1. Limit the set of covered files to those files in paths listed in the `include` array.
235
+
1. Limit the set of instrumented files to those files in paths listed in the `include` array.
235
236
2. Remove any files that are found in the `exclude` array.
236
-
3. Restore any exclude negated files that have been excluded in the second step.
237
+
3. Restore any exclude negated files that have been excluded in step 2.
237
238
238
239
### Using include and exclude arrays
239
240
240
-
If there are paths specified in the `include` array, then the set of covered files will be limited to eligible files found in those paths.
241
+
If there are paths specified in the `include` array, then the set of instrumented files will be limited to eligible files found in those paths.
241
242
If the `include` array is left undefined all eligible files will be included, equivalent to setting `include: ['**']`.
242
-
Include options can be specified on the command line with the`-n` switch.
243
+
Multiple `include` globs can be specified on the command line, each must follow a `--include`,`-n` switch.
243
244
244
-
If there are paths specified in the `exclude` array, then the set of covered files will not feature eligible files found in those paths.
245
+
If there are paths specified in the `exclude` array, then the set of instrumented files will not feature eligible files found in those paths.
245
246
You can also specify negated paths in the `exclude` array, by prefixing them with a `!`.
246
247
Negated paths can restore paths that have been already been excluded in the `exclude` array.
247
-
Exclude options can be specified on the command line with the`-x` switch.
248
+
Multiple `exclude` globs can be specified on the command line, each must follow a `--exclude`,`-x` switch.
248
249
249
250
The `exclude` option has the following defaults settings:
250
251
```js
@@ -298,7 +299,7 @@ modules should be required in the subprocess collecting coverage:
298
299
299
300
## Configuring `nyc`
300
301
301
-
Any configuration options that can be set via the command line can also be specified in the `nyc` stanza of your package.json, or within a `.nycrc` (or `.nycrc.json`) file:
302
+
Any configuration options that can be set via the command line can also be specified in the `nyc` stanza of your package.json, or within a `.nycrc`, `.nycrc.json`, or `nyc.config.js` file:
0 commit comments