Skip to content

Commit

Permalink
Coverage directory option added
Browse files Browse the repository at this point in the history
Summary:Solves jestjs#908.
Closes jestjs#909

Reviewed By: cpojer

Differential Revision: D3190247

fb-gh-sync-id: a9424dc075dbdecb231d4748438d0a496465a53c
fbshipit-source-id: a9424dc075dbdecb231d4748438d0a496465a53c
  • Loading branch information
EnoahNetzach authored and Facebook Github Bot 0 committed Apr 18, 2016
1 parent 86250ac commit 7405e08
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ Jest uses Jasmine 2 by default. An introduction to Jasmine 2 can be found
- [`bail` [boolean]](https://facebook.github.io/jest/docs/api.html#bail-boolean)
- [`cache` [boolean]](https://facebook.github.io/jest/docs/api.html#cache-boolean)
- [`cacheDirectory` [string]](https://facebook.github.io/jest/docs/api.html#cachedirectory-string)
- [`coverageDirectory` [string]](https://facebook.github.io/jest/docs/api.html#coveragedirectory-string)
- [`collectCoverage` [boolean]](https://facebook.github.io/jest/docs/api.html#collectcoverage-boolean)
- [`collectCoverageOnlyFrom` [object]](https://facebook.github.io/jest/docs/api.html#collectcoverageonlyfrom-object)
- [`globals` [object]](https://facebook.github.io/jest/docs/api.html#globals-object)
Expand Down
6 changes: 6 additions & 0 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ Jest uses Jasmine 2 by default. An introduction to Jasmine 2 can be found
- [`bail` [boolean]](#bail-boolean)
- [`cache` [boolean]](#cache-boolean)
- [`cacheDirectory` [string]](#cachedirectory-string)
- [`coverageDirectory` [string]](#coveragedirectory-string)
- [`collectCoverage` [boolean]](#collectcoverage-boolean)
- [`collectCoverageOnlyFrom` [object]](#collectcoverageonlyfrom-object)
- [`globals` [object]](#globals-object)
Expand Down Expand Up @@ -390,6 +391,11 @@ Jest attempts to scan your dependency tree once (up-front) and cache it in order

By default, it will be stored in a .haste_cache directory that sits in the jest-cli directory. This intentionally doesn't default to somewhere in your repo to spare the common case from having to add this to your .gitignore/.hgignore/etc.

### `coverageDirectory` [string]
(default: `undefined`)

The directory where Jest should output its coverage files.

### `collectCoverage` [boolean]
(default: `false`)

Expand Down
1 change: 1 addition & 0 deletions src/config/normalize.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ function normalize(config, argv) {
break;

case 'cacheDirectory':
case 'coverageDirectory':
case 'testRunner':
case 'scriptPreprocessor':
case 'setupTestFrameworkScriptFile':
Expand Down
3 changes: 3 additions & 0 deletions src/reporters/IstanbulTestReporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ class IstanbulTestReporter extends DefaultTestReporter {

if (config.collectCoverage) {
try {
if (config.coverageDirectory) {
reporter.dir = config.coverageDirectory;
}
reporter.addAll(config.coverageReporters);
reporter.write(collector, true, () => {});
} catch (e) {}
Expand Down

0 comments on commit 7405e08

Please sign in to comment.