Skip to content

Commit

Permalink
Coverage option for editor support
Browse files Browse the repository at this point in the history
When using the Jest extension in vscode, running coverage is often slow so it would be nice to be able to turn it on and off as needed.

Add a coverage option to the runner.
  • Loading branch information
Nathan L Smith committed Mar 20, 2018
1 parent 124067e commit eced855
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/jest-editor-support/src/Runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ export default class Runner extends EventEmitter {
if (this.options.testFileNamePattern) {
args.push(this.options.testFileNamePattern);
}
if (this.options.coverage) {
args.push('--coverage');
}

const options = {
shell: this.options.shell,
Expand Down
13 changes: 13 additions & 0 deletions packages/jest-editor-support/src/__tests__/runner.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,19 @@ describe('Runner', () => {
expect((createProcess: any).mock.calls[0][1]).toContain('--watch');
});

it('calls createProcess with the --coverage arg when provided', () => {
const expected = '--coverage';

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

const args = (createProcess: any).mock.calls[0][1];
const index = args.indexOf(expected);
expect(index).not.toBe(-1);
});

it('calls createProcess with the --testNamePattern arg when provided', () => {
const expected = 'testNamePattern';

Expand Down
1 change: 1 addition & 0 deletions packages/jest-editor-support/src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ 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 eced855

Please sign in to comment.