Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support multiple glob patterns for collectCoverageFrom #5537

Merged
merged 3 commits into from
Feb 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,17 @@
`assert`, `count`, `countReset`, `dir`, `dirxml`, `group`, `groupCollapsed`,
`groupEnd`, `time`, `timeEnd`
([#5514](https://github.com/facebook/jest/pull/5514))
* `[docs]` Add documentation for interactive snapshot mode ([#5291](https://github.com/facebook/jest/pull/5291))
* `[jest-editor-support]` Add watchAll flag ([#5523](https://github.com/facebook/jest/pull/5523))
* `[docs]` Add documentation for interactive snapshot mode
([#5291](https://github.com/facebook/jest/pull/5291))
* `[jest-editor-support]` Add watchAll flag
([#5523](https://github.com/facebook/jest/pull/5523))
* `[jest-cli]` Support multiple glob patterns for `collectCoverageFrom`
([#5537](https://github.com/facebook/jest/pull/5537))

### Chore & Maintenance

* `[jest-config]` Allow `<rootDir>` to be used with `collectCoverageFrom` ([#5524](https://github.com/facebook/jest/pull/5524))
* `[jest-config]` Allow `<rootDir>` to be used with `collectCoverageFrom`
([#5524](https://github.com/facebook/jest/pull/5524))

## jest 22.2.2

Expand Down Expand Up @@ -154,7 +159,8 @@
* `[jest-cli]` Make Jest exit without an error when no tests are found in the
case of `--lastCommit`, `--findRelatedTests`, or `--onlyChanged` options
having been passed to the CLI
* `[jest-cli]` Add interactive snapshot mode ([#3831](https://github.com/facebook/jest/pull/3831))
* `[jest-cli]` Add interactive snapshot mode
([#3831](https://github.com/facebook/jest/pull/3831))

### Fixes

Expand Down
2 changes: 1 addition & 1 deletion docs/CLI.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ directory. The default cache directory can be found by calling

### `--collectCoverageFrom=<glob>`

Relative to the root directory, glob pattern matching the files that coverage
An array of glob patterns relative to <rootDir> matching the files that coverage
info needs to be collected from.

### `--colors`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,18 @@ All files | 100 | 100 | 100 | 100 | |
"
`;

exports[`collects coverage only from specified files 1`] = `
exports[`collects coverage only from multiple specified files 1`] = `
"---------------|----------|----------|----------|----------|----------------|
File | % Stmts | % Branch | % Funcs | % Lines |Uncovered Lines |
---------------|----------|----------|----------|----------|----------------|
All files | 100 | 100 | 100 | 100 | |
other-file.js | 100 | 100 | 100 | 100 | |
setup.js | 100 | 100 | 100 | 100 | |
---------------|----------|----------|----------|----------|----------------|
"
`;

exports[`collects coverage only from specified file 1`] = `
"----------|----------|----------|----------|----------|----------------|
File | % Stmts | % Branch | % Funcs | % Lines |Uncovered Lines |
----------|----------|----------|----------|----------|----------------|
Expand Down
14 changes: 13 additions & 1 deletion integration-tests/__tests__/coverage_report.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ test('outputs coverage report', () => {
expect(status).toBe(0);
});

test('collects coverage only from specified files', () => {
test('collects coverage only from specified file', () => {
const {stdout} = runJest(DIR, [
'--no-cache',
'--coverage',
Expand All @@ -45,6 +45,18 @@ test('collects coverage only from specified files', () => {
expect(stdout).toMatchSnapshot();
});

test('collects coverage only from multiple specified files', () => {
const {stdout} = runJest(DIR, [
'--no-cache',
'--coverage',
'--collectCoverageFrom', // overwrites the one in package.json
'setup.js',
'other-file.js',
]);

expect(stdout).toMatchSnapshot();
});

test('collects coverage only from specified files avoiding dependencies', () => {
const {stdout} = runJest(DIR, [
'--no-cache',
Expand Down
4 changes: 2 additions & 2 deletions packages/jest-cli/src/cli/args.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@ export const options = {
},
collectCoverageFrom: {
description:
'relative to <rootDir> glob pattern matching the files ' +
'An array of glob patterns relative to <rootDir> matching the files ' +
'that coverage info needs to be collected from.',
type: 'string',
type: 'array',
},
collectCoverageOnlyFrom: {
description: 'Explicit list of paths coverage will be restricted to.',
Expand Down