Skip to content

Commit

Permalink
Move Options.coverage to ProjectWorkspace.collectCoverage (#5929)
Browse files Browse the repository at this point in the history
* update type definitions

* Move `Options.coverage` to `ProjectWorkspace.collectCoverage`

* mark collectCoverage as optional

* fix failing test

* update changelog
  • Loading branch information
stephtr authored and orta committed Apr 9, 2018
1 parent aa9790d commit f6ae2cb
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 8 deletions.
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

0 comments on commit f6ae2cb

Please sign in to comment.