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

Move Options.coverage to ProjectWorkspace.collectCoverage #5929

Merged
merged 6 commits into from
Apr 9, 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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

### Features

* `[jest-editor-support]` Move `coverage` to `ProjectWorkspace.collectCoverage`
([#5929](https://github.com/facebook/jest/pull/5929))
* `[jest-editor-support]` Add `coverage` option to runner
([#5836](https://github.com/facebook/jest/pull/5836))
* `[jest-haste-map]` Support extracting dynamic `import`s
Expand Down
3 changes: 2 additions & 1 deletion packages/jest-editor-support/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export interface SpawnOptions {
}

export interface Options {
coverage?: boolean;
createProcess?(
workspace: ProjectWorkspace,
args: string[],
Expand Down Expand Up @@ -49,11 +48,13 @@ export class ProjectWorkspace {
pathToJest: string,
pathToConfig: string,
localJestMajorVersin: number,
collectCoverage?: boolean,
);
pathToJest: string;
pathToConfig: string;
rootPath: string;
localJestMajorVersion: number;
collectCoverage?: boolean;
}

export interface IParseResults {
Expand Down
4 changes: 2 additions & 2 deletions packages/jest-editor-support/src/Runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ export default class Runner extends EventEmitter {
if (this.options.testFileNamePattern) {
args.push(this.options.testFileNamePattern);
}
if (this.options.coverage === true) {
if (this.workspace.collectCoverage === true) {
args.push('--coverage');
}
if (this.options.coverage === false) {
if (this.workspace.collectCoverage === false) {
args.push('--no-coverage');
}
if (this.options.noColor === true) {
Expand Down
8 changes: 4 additions & 4 deletions packages/jest-editor-support/src/__tests__/runner.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ describe('Runner', () => {
it('calls createProcess with the --coverage arg when provided', () => {
const expected = '--coverage';

const workspace: any = {};
const options = {coverage: true};
const workspace: any = {collectCoverage: true};
const options = {};
const sut = new Runner(workspace, options);
sut.start(false);

Expand All @@ -196,8 +196,8 @@ describe('Runner', () => {
it('calls createProcess with the ---no-coverage arg when provided and false', () => {
const expected = '--no-coverage';

const workspace: any = {};
const options = {coverage: false};
const workspace: any = {collectCoverage: false};
const options = {};
const sut = new Runner(workspace, options);
sut.start(false);

Expand Down
9 changes: 9 additions & 0 deletions packages/jest-editor-support/src/project_workspace.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,24 @@ export default class ProjectWorkspace {
*/
localJestMajorVersion: number;

/**
* Whether test coverage should be (automatically) collected.
*
* @type {boolean}
*/
collectCoverage: ?boolean;

constructor(
rootPath: string,
pathToJest: string,
pathToConfig: string,
localJestMajorVersion: number,
collectCoverage: ?boolean,
) {
this.rootPath = rootPath;
this.pathToJest = pathToJest;
this.pathToConfig = pathToConfig;
this.localJestMajorVersion = localJestMajorVersion;
this.collectCoverage = collectCoverage;
}
}
1 change: 0 additions & 1 deletion packages/jest-editor-support/src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import type {ChildProcess} from 'child_process';
import type ProjectWorkspace from './project_workspace';

export type Options = {
coverage?: boolean,
createProcess?: (
workspace: ProjectWorkspace,
args: Array<string>,
Expand Down