Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add watchAll flag to jest-editor-support #5523

Merged
merged 2 commits into from
Feb 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
`groupEnd`, `time`, `timeEnd`
([#5514](https://github.com/facebook/jest/pull/5514))
* `[docs]` Add documentation for interactive snapshot mode ([#5291](https://github.com/facebook/jest/pull/5291))
* `[jest-editor-support]` Add watchAll flag ([#5523](https://github.com/facebook/jest/pull/5523))

## jest 22.2.2

Expand Down
3 changes: 2 additions & 1 deletion packages/jest-editor-support/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ export interface Options {
export class Runner extends EventEmitter {
constructor(workspace: ProjectWorkspace, options?: Options);
watchMode: boolean;
start(watchMode?: boolean): void;
watchAll: boolean;
start(watchMode?: boolean, watchAll?: boolean): void;
closeProcess(): void;
runJestWithUpdateForSnapshots(completion: any): void;
}
Expand Down
6 changes: 4 additions & 2 deletions packages/jest-editor-support/src/Runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export default class Runner extends EventEmitter {
options?: SpawnOptions,
) => ChildProcess;
watchMode: boolean;
watchAll: boolean;
options: Options;
prevMessageTypes: MessageType[];

Expand All @@ -43,20 +44,21 @@ export default class Runner extends EventEmitter {
this.prevMessageTypes = [];
}

start(watchMode: boolean = true) {
start(watchMode: boolean = true, watchAll: boolean = false) {
if (this.debugprocess) {
return;
}

this.watchMode = watchMode;
this.watchAll = watchAll;

// Handle the arg change on v18
const belowEighteen = this.workspace.localJestMajorVersion < 18;
const outputArg = belowEighteen ? '--jsonOutputFile' : '--outputFile';

const args = ['--json', '--useStderr', outputArg, this.outputPath];
if (this.watchMode) {
args.push('--watch');
args.push(this.watchAll ? '--watchAll' : '--watch');
}
if (this.options.testNamePattern) {
args.push('--testNamePattern', this.options.testNamePattern);
Expand Down
19 changes: 19 additions & 0 deletions packages/jest-editor-support/src/__tests__/runner.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ describe('Runner', () => {
expect(sut.watchMode).not.toBeDefined();
});

it('does not set watchAll', () => {
const workspace: any = {};
const sut = new Runner(workspace);

expect(sut.watchAll).not.toBeDefined();
});

it('sets the output filepath', () => {
tmpdir.mockReturnValueOnce('tmpdir');

Expand Down Expand Up @@ -107,6 +114,18 @@ describe('Runner', () => {
expect(sut.watchMode).toBe(expected);
});

it('sets watchAll', () => {
const watchMode = true;
const watchAll = true;

const workspace: any = {};
const sut = new Runner(workspace);
sut.start(watchMode, watchAll);

expect(sut.watchMode).toBe(watchMode);
expect(sut.watchAll).toBe(watchAll);
});

it('calls createProcess', () => {
const workspace: any = {};
const sut = new Runner(workspace);
Expand Down