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
Copy file name to clipboardExpand all lines: README.md
+18-1Lines changed: 18 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -195,6 +195,24 @@ Install custom reporters as a development dependency and you can use the `--repo
195
195
nyc report --reporter=<custom-reporter-name>
196
196
```
197
197
198
+
## Setting the project root directory
199
+
200
+
nyc runs a lot of file system operations relative to the project root directory.
201
+
During startup nyc will look for the *default* project root directory.
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.
204
+
You can change the project root directory with the `--cwd` option.
205
+
206
+
nyc uses the project root directory when:
207
+
* looking for source files to cover
208
+
* creating globs for include and exclude rules during file selection
209
+
* loading custom require hooks from the `require` array
210
+
211
+
nyc may create artefact directories within the project root, such as:
212
+
* the report directory, `<project-root>/coverage`
213
+
* the cache directory, `<project-root>/node_modules/.cache/nyc`
214
+
* the temp directory, `<project-root>/.nyc_output`
215
+
198
216
## Selecting files for coverage
199
217
200
218
By default, nyc only collects coverage for source files that are visited during a test.
@@ -217,7 +235,6 @@ We use the following process to remove files from consideration:
217
235
2. Remove any files that are found in the `exclude` array.
218
236
3. Restore any exclude negated files that have been excluded in the second step.
219
237
220
-
221
238
### Using include and exclude arrays
222
239
223
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.
0 commit comments