diff --git a/packages/jest-editor-support/src/Runner.js b/packages/jest-editor-support/src/Runner.js index 4acfa3873b8e..409d1174f2e4 100644 --- a/packages/jest-editor-support/src/Runner.js +++ b/packages/jest-editor-support/src/Runner.js @@ -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, diff --git a/packages/jest-editor-support/src/__tests__/runner.test.js b/packages/jest-editor-support/src/__tests__/runner.test.js index 3253d1be9150..289de59722d3 100644 --- a/packages/jest-editor-support/src/__tests__/runner.test.js +++ b/packages/jest-editor-support/src/__tests__/runner.test.js @@ -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'; diff --git a/packages/jest-editor-support/src/types.js b/packages/jest-editor-support/src/types.js index 22debbe9296d..e8708eb2133f 100644 --- a/packages/jest-editor-support/src/types.js +++ b/packages/jest-editor-support/src/types.js @@ -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,