From 805a69c82854d712dcb689239cb2c90a9700de11 Mon Sep 17 00:00:00 2001 From: Stephan Date: Thu, 5 Apr 2018 12:01:13 +0200 Subject: [PATCH 1/5] update type definitions --- packages/jest-editor-support/index.d.ts | 2 ++ packages/jest-editor-support/src/project_workspace.js | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/packages/jest-editor-support/index.d.ts b/packages/jest-editor-support/index.d.ts index 3382c4b14262..1c31e6c24925 100644 --- a/packages/jest-editor-support/index.d.ts +++ b/packages/jest-editor-support/index.d.ts @@ -47,11 +47,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 { diff --git a/packages/jest-editor-support/src/project_workspace.js b/packages/jest-editor-support/src/project_workspace.js index 69aff307af0e..8e068a4fdb86 100644 --- a/packages/jest-editor-support/src/project_workspace.js +++ b/packages/jest-editor-support/src/project_workspace.js @@ -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; } } From c8c16ccc665dba8105334ab1f5226176495fc390 Mon Sep 17 00:00:00 2001 From: Stephan Date: Thu, 5 Apr 2018 12:12:57 +0200 Subject: [PATCH 2/5] Move `Options.coverage` to `ProjectWorkspace.collectCoverage` --- CHANGELOG.md | 3 +++ packages/jest-editor-support/index.d.ts | 1 - packages/jest-editor-support/src/Runner.js | 4 ++-- packages/jest-editor-support/src/__tests__/runner.test.js | 8 ++++---- packages/jest-editor-support/src/project_workspace.js | 2 +- packages/jest-editor-support/src/types.js | 1 - 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6871fc0ca351..bef1fc66377e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ ## master +* `[jest-editor-support]` Move `Options.coverage` to `ProjectWorkspace.collectCoverage` + ([#](https://github.com/facebook/jest/pull/)) + ### Features * `[jest-editor-support]` Add `coverage` option to runner diff --git a/packages/jest-editor-support/index.d.ts b/packages/jest-editor-support/index.d.ts index 17f7317d2074..9e9983520fe7 100644 --- a/packages/jest-editor-support/index.d.ts +++ b/packages/jest-editor-support/index.d.ts @@ -13,7 +13,6 @@ export interface SpawnOptions { } export interface Options { - coverage?: boolean; createProcess?( workspace: ProjectWorkspace, args: string[], diff --git a/packages/jest-editor-support/src/Runner.js b/packages/jest-editor-support/src/Runner.js index 2f7e571da6ec..8bd124625ad6 100644 --- a/packages/jest-editor-support/src/Runner.js +++ b/packages/jest-editor-support/src/Runner.js @@ -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) { diff --git a/packages/jest-editor-support/src/__tests__/runner.test.js b/packages/jest-editor-support/src/__tests__/runner.test.js index 3a8f59bca457..19bdaf35719a 100644 --- a/packages/jest-editor-support/src/__tests__/runner.test.js +++ b/packages/jest-editor-support/src/__tests__/runner.test.js @@ -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); @@ -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); diff --git a/packages/jest-editor-support/src/project_workspace.js b/packages/jest-editor-support/src/project_workspace.js index 8e068a4fdb86..9cac2d14a191 100644 --- a/packages/jest-editor-support/src/project_workspace.js +++ b/packages/jest-editor-support/src/project_workspace.js @@ -47,7 +47,7 @@ export default class ProjectWorkspace { localJestMajorVersion: number; /** - * Whether test coverage should be automatically collected. + * Whether test coverage should be (automatically) collected. * * @type {boolean} */ diff --git a/packages/jest-editor-support/src/types.js b/packages/jest-editor-support/src/types.js index 99d506a1aec2..74de73414479 100644 --- a/packages/jest-editor-support/src/types.js +++ b/packages/jest-editor-support/src/types.js @@ -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, From cdcd22cc33d2de33f9a3365327d06028a9a8ae17 Mon Sep 17 00:00:00 2001 From: Stephan Date: Thu, 5 Apr 2018 12:15:20 +0200 Subject: [PATCH 3/5] mark collectCoverage as optional --- packages/jest-editor-support/index.d.ts | 4 ++-- packages/jest-editor-support/src/project_workspace.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/jest-editor-support/index.d.ts b/packages/jest-editor-support/index.d.ts index 9e9983520fe7..dfc7bb64c330 100644 --- a/packages/jest-editor-support/index.d.ts +++ b/packages/jest-editor-support/index.d.ts @@ -48,13 +48,13 @@ export class ProjectWorkspace { pathToJest: string, pathToConfig: string, localJestMajorVersin: number, - collectCoverage: boolean, + collectCoverage?: boolean, ); pathToJest: string; pathToConfig: string; rootPath: string; localJestMajorVersion: number; - collectCoverage: boolean; + collectCoverage?: boolean; } export interface IParseResults { diff --git a/packages/jest-editor-support/src/project_workspace.js b/packages/jest-editor-support/src/project_workspace.js index 9cac2d14a191..bc2bb1cf2e42 100644 --- a/packages/jest-editor-support/src/project_workspace.js +++ b/packages/jest-editor-support/src/project_workspace.js @@ -51,14 +51,14 @@ export default class ProjectWorkspace { * * @type {boolean} */ - collectCoverage: boolean; + collectCoverage: ?boolean; constructor( rootPath: string, pathToJest: string, pathToConfig: string, localJestMajorVersion: number, - collectCoverage: boolean, + collectCoverage: ?boolean, ) { this.rootPath = rootPath; this.pathToJest = pathToJest; From 3b71e7e213b7004081ad4d44814854aebaec388e Mon Sep 17 00:00:00 2001 From: Stephan Date: Thu, 5 Apr 2018 12:30:51 +0200 Subject: [PATCH 4/5] fix failing test --- packages/jest-editor-support/src/__tests__/runner.test.js | 4 ++-- packages/jest-editor-support/src/project_workspace.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/jest-editor-support/src/__tests__/runner.test.js b/packages/jest-editor-support/src/__tests__/runner.test.js index 19bdaf35719a..ac6557dcc4c5 100644 --- a/packages/jest-editor-support/src/__tests__/runner.test.js +++ b/packages/jest-editor-support/src/__tests__/runner.test.js @@ -183,7 +183,7 @@ describe('Runner', () => { it('calls createProcess with the --coverage arg when provided', () => { const expected = '--coverage'; - const workspace: any = { collectCoverage: true }; + const workspace: any = {collectCoverage: true}; const options = {}; const sut = new Runner(workspace, options); sut.start(false); @@ -196,7 +196,7 @@ describe('Runner', () => { it('calls createProcess with the ---no-coverage arg when provided and false', () => { const expected = '--no-coverage'; - const workspace: any = { collectCoverage: false }; + const workspace: any = {collectCoverage: false}; const options = {}; const sut = new Runner(workspace, options); sut.start(false); diff --git a/packages/jest-editor-support/src/project_workspace.js b/packages/jest-editor-support/src/project_workspace.js index bc2bb1cf2e42..10c5540f5c6f 100644 --- a/packages/jest-editor-support/src/project_workspace.js +++ b/packages/jest-editor-support/src/project_workspace.js @@ -48,7 +48,7 @@ export default class ProjectWorkspace { /** * Whether test coverage should be (automatically) collected. - * + * * @type {boolean} */ collectCoverage: ?boolean; From 9d81de7b8f4532a9d8dac10abf033de9bd98a57a Mon Sep 17 00:00:00 2001 From: Stephan Date: Mon, 9 Apr 2018 11:24:43 +0200 Subject: [PATCH 5/5] update changelog --- CHANGELOG.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bef1fc66377e..4d386fdca0ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,9 @@ ## master -* `[jest-editor-support]` Move `Options.coverage` to `ProjectWorkspace.collectCoverage` - ([#](https://github.com/facebook/jest/pull/)) - ### 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