Skip to content

Commit d4e5afa

Browse files
boujeepossumcpojer
authored andcommitted
collectCoverageFrom docs (jestjs#1724)
* collectCoverageFrom docs * Update API.md
1 parent 3fd73bd commit d4e5afa

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

docs/API.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ These options let you control Jest's behavior in your `package.json` file. The J
100100
- [`coverageDirectory` [string]](#coveragedirectory-string)
101101
- [`coverageReporters` [array<string>]](#coveragereporters-array-string)
102102
- [`collectCoverage` [boolean]](#collectcoverage-boolean)
103-
- [`collectCoverageOnlyFrom` [object]](#collectcoverageonlyfrom-object)
103+
- [`collectCoverageFrom` [object]](#collectcoveragefrom-object)
104104
- [`coveragePathIgnorePatterns` [array<string>]](#coveragepathignorepattern-array-string)
105105
- [`coverageThreshold` [object]](#coveragethreshold-object)
106106
- [`globals` [object]](#globals-object)
@@ -969,10 +969,23 @@ A list of reporter names that Jest uses when writing coverage reports. Any [ista
969969

970970
Indicates whether the coverage information should be collected while executing the test. Because this retrofits all executed files with coverage collection statements, it may significantly slow down your tests.
971971

972-
### `collectCoverageOnlyFrom` [object]
972+
### `collectCoverageFrom` [object]
973973
(default: `undefined`)
974974

975-
An object that, when present, indicates a set of files for which coverage information should be collected. Any files not present in this set will not have coverage collected for them. Since there is a performance cost for each file that we collect coverage information from, this can help prune this cost down to only the files in which you care about coverage (such as the specific modules that you are testing).
975+
An array of [glob patterns](https://github.com/sindresorhus/multimatch)
976+
indicating a set of files for which coverage information should be collected. If a file matches
977+
the specified glob pattern, coverage information will be collected for it even if no tests exist for
978+
this file and it's never required in the test suite.
979+
980+
Example:
981+
```js
982+
collectCoverageFrom: ['**/*.{js,jsx}', '!**/node_modules/**', '!**/vendor/**']
983+
```
984+
985+
This will collect coverage information for all the files inside the project's `rootDir`, except the ones that match
986+
`**/node_modules/**` or `**/vendor/**`.
987+
988+
*Note: This option requires `collectCoverage` to be set to true or Jest to be invoked with `--coverage`.*
976989

977990
### `coveragePathIgnorePatterns` [array<string>]
978991
(default: `['/node_modules/']`)

0 commit comments

Comments
 (0)