diff --git a/CHANGELOG.md b/CHANGELOG.md index e8042687ffc9..c319aaff8217 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,9 @@ ([#5826](https://github.com/facebook/jest/pull/5826)) * `[jest-cli]` Interactive Snapshot Mode improvements ([#5864](https://github.com/facebook/jest/pull/5864)) + * `[jest-editor-support]` Add `no-color` option to runner + ([#5909](https://github.com/facebook/jest/pull/5909)) + ### Fixes diff --git a/packages/jest-editor-support/index.d.ts b/packages/jest-editor-support/index.d.ts index 68891c7988f6..67230c116415 100644 --- a/packages/jest-editor-support/index.d.ts +++ b/packages/jest-editor-support/index.d.ts @@ -19,6 +19,7 @@ export interface Options { args: string[], options?: SpawnOptions, ): ChildProcess; + noColor?: boolean; testNamePattern?: string; testFileNamePattern?: string; shell?: boolean; @@ -171,7 +172,7 @@ export interface SnapshotMetadata { exists: boolean; name: string; node: { - loc: Node + loc: Node; }; content?: string; } @@ -179,4 +180,4 @@ export interface SnapshotMetadata { export class Snapshot { constructor(parser: any, customMatchers?: string[]); getMetadata(filepath: string): SnapshotMetadata[]; -} \ No newline at end of file +} diff --git a/packages/jest-editor-support/src/Runner.js b/packages/jest-editor-support/src/Runner.js index c51e08adb4b7..2f7e571da6ec 100644 --- a/packages/jest-editor-support/src/Runner.js +++ b/packages/jest-editor-support/src/Runner.js @@ -72,6 +72,9 @@ export default class Runner extends EventEmitter { if (this.options.coverage === false) { args.push('--no-coverage'); } + if (this.options.noColor === true) { + args.push('--no-color'); + } 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 22e618809c87..3a8f59bca457 100644 --- a/packages/jest-editor-support/src/__tests__/runner.test.js +++ b/packages/jest-editor-support/src/__tests__/runner.test.js @@ -251,6 +251,17 @@ describe('Runner', () => { expect((createProcess: any).mock.calls[0][2]).toEqual({shell: true}); }); + + it('calls createProcess with the no color option when provided', () => { + const expected = '--no-color'; + + const workspace: any = {}; + const options = {noColor: true}; + const sut = new Runner(workspace, options); + sut.start(false); + + expect((createProcess: any).mock.calls[0][1]).toContain(expected); + }); }); describe('closeProcess', () => { diff --git a/packages/jest-editor-support/src/types.js b/packages/jest-editor-support/src/types.js index e8708eb2133f..99d506a1aec2 100644 --- a/packages/jest-editor-support/src/types.js +++ b/packages/jest-editor-support/src/types.js @@ -26,6 +26,7 @@ export type Options = { args: Array, options?: SpawnOptions, ) => ChildProcess, + noColor?: boolean, testNamePattern?: string, testFileNamePattern?: string, shell?: boolean,