-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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 different coverage options in projects #9633
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,3 +44,5 @@ junit.xml | |
.yarn/unplugged/ | ||
.yarn/build-state.yml | ||
e2e/async-regenerator/.yarn/ | ||
|
||
/.history |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -157,8 +157,6 @@ For stability and safety reasons, only part of the global configuration keys can | |
- [`bail`](configuration.html#bail-number--boolean) | ||
- [`changedSince`](cli.html#--changedsince) | ||
- [`collectCoverage`](configuration.html#collectcoverage-boolean) | ||
- [`collectCoverageFrom`](configuration.html#collectcoveragefrom-array) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think watch plugins should still be able to set these, somehow... Might have to solve watchplugins setting project options before we can land this |
||
- [`collectCoverageOnlyFrom`](configuration.html#collectcoverageonlyfrom-array) | ||
- [`coverageDirectory`](configuration.html#coveragedirectory-string) | ||
- [`coverageReporters`](configuration.html#coveragereporters-arraystring) | ||
- [`notify`](configuration.html#notify-boolean) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`outputs coverage report 1`] = ` | ||
----------------|---------|----------|---------|---------|------------------- | ||
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s | ||
----------------|---------|----------|---------|---------|------------------- | ||
All files | 100 | 100 | 100 | 100 | | ||
add | 100 | 100 | 100 | 100 | | ||
index.js | 100 | 100 | 100 | 100 | | ||
mul | 100 | 100 | 100 | 100 | | ||
other_file.js | 100 | 100 | 100 | 100 | | ||
----------------|---------|----------|---------|---------|------------------- | ||
`; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import * as fs from 'fs'; | ||
import * as path from 'path'; | ||
import {wrap} from 'jest-snapshot-serializer-raw'; | ||
import {run} from '../Utils'; | ||
import runJest from '../runJest'; | ||
|
||
const DIR = path.resolve(__dirname, '../coverage-projects'); | ||
|
||
beforeAll(() => { | ||
run('yarn', DIR); | ||
}); | ||
|
||
test('outputs coverage report', () => { | ||
const {stdout, exitCode} = runJest(DIR, ['--no-cache', '--coverage'], { | ||
stripAnsi: true, | ||
}); | ||
const coverageDir = path.join(DIR, 'coverage'); | ||
|
||
// - the `index.js` file in package `mul` is ignored and should not be in the | ||
// coverage report. | ||
expect(wrap(stdout)).toMatchSnapshot(); | ||
|
||
// `index.js` should only appear once (in package `add`) | ||
expect(stdout.match(/index\.js/g)).toHaveLength(1); | ||
|
||
expect(() => fs.accessSync(coverageDir, fs.F_OK)).not.toThrow(); | ||
expect(exitCode).toBe(0); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
coverage | ||
yarn-error.log |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"private": true, | ||
"workspaces": { | ||
"packages": [ | ||
"packages/*" | ||
] | ||
}, | ||
"jest": { | ||
"collectCoverage": true, | ||
"projects": ["packages/*"] | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
module.exports = (x, y) => x + y; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
const add = require('.'); | ||
|
||
describe('add', () => { | ||
it('should add correctly', () => { | ||
expect(add(2, 3)).toBe(5); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"name": "add", | ||
"private": true, | ||
"jest": { | ||
"collectCoverage": true, | ||
"collectCoverageFrom": [ | ||
"!**.json", | ||
"!<rootDir>/coverage/**" | ||
] | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
module.exports = (x, y) => x * y; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
const mul = require('.'); | ||
|
||
describe('mul', () => { | ||
it('should multiply correctly', () => { | ||
expect(mul(2, 3)).toBe(6); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
module.exports = () => 'hello'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
const hello = require('./other_file'); | ||
|
||
describe('other_file', () => { | ||
it('should output hello', () => { | ||
expect(hello()).toBe('hello'); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"name": "mul", | ||
"private": true, | ||
"jest": { | ||
"collectCoverage": true, | ||
"collectCoverageFrom": [ | ||
"!**.json", | ||
"!<rootDir>/coverage/**", | ||
"!<rootDir>/index.js" | ||
] | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. | ||
# yarn lockfile v1 | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,6 +61,7 @@ module.exports = { | |
'/packages/jest-worker/src/__performance_tests__', | ||
'/packages/pretty-format/perf/test.js', | ||
'/e2e/__tests__/iterator-to-null-test.ts', | ||
'/.history', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what's this directory? |
||
], | ||
transform: { | ||
'^.+\\.[jt]sx?$': '<rootDir>/packages/babel-jest', | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not all the
coverage*
options?