Skip to content

Commit

Permalink
Add an option to use --no-color chalk CLI argument
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean Poulter authored and orta committed Apr 2, 2018
1 parent 10b50c4 commit e3f596d
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 3 additions & 2 deletions packages/jest-editor-support/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export interface Options {
args: string[],
options?: SpawnOptions,
): ChildProcess;
noColor?: boolean;
testNamePattern?: string;
testFileNamePattern?: string;
shell?: boolean;
Expand Down Expand Up @@ -171,12 +172,12 @@ export interface SnapshotMetadata {
exists: boolean;
name: string;
node: {
loc: Node
loc: Node;
};
content?: string;
}

export class Snapshot {
constructor(parser: any, customMatchers?: string[]);
getMetadata(filepath: string): SnapshotMetadata[];
}
}
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 @@ -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,
Expand Down
11 changes: 11 additions & 0 deletions packages/jest-editor-support/src/__tests__/runner.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
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 @@ -26,6 +26,7 @@ export type Options = {
args: Array<string>,
options?: SpawnOptions,
) => ChildProcess,
noColor?: boolean,
testNamePattern?: string,
testFileNamePattern?: string,
shell?: boolean,
Expand Down

0 comments on commit e3f596d

Please sign in to comment.