Skip to content

Commit e9bf143

Browse files
k15aorta
authored andcommitted
Add watchAll flag to jest-editor-support (#5523)
* Add watchAll flag to jest-editor-support * Add changelog
1 parent af19110 commit e9bf143

4 files changed

Lines changed: 26 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
`groupEnd`, `time`, `timeEnd`
88
([#5514](https://github.com/facebook/jest/pull/5514))
99
* `[docs]` Add documentation for interactive snapshot mode ([#5291](https://github.com/facebook/jest/pull/5291))
10+
* `[jest-editor-support]` Add watchAll flag ([#5523](https://github.com/facebook/jest/pull/5523))
1011

1112
## jest 22.2.2
1213

packages/jest-editor-support/index.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ export interface Options {
2222
export class Runner extends EventEmitter {
2323
constructor(workspace: ProjectWorkspace, options?: Options);
2424
watchMode: boolean;
25-
start(watchMode?: boolean): void;
25+
watchAll: boolean;
26+
start(watchMode?: boolean, watchAll?: boolean): void;
2627
closeProcess(): void;
2728
runJestWithUpdateForSnapshots(completion: any): void;
2829
}

packages/jest-editor-support/src/Runner.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export default class Runner extends EventEmitter {
3030
options?: SpawnOptions,
3131
) => ChildProcess;
3232
watchMode: boolean;
33+
watchAll: boolean;
3334
options: Options;
3435
prevMessageTypes: MessageType[];
3536

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

46-
start(watchMode: boolean = true) {
47+
start(watchMode: boolean = true, watchAll: boolean = false) {
4748
if (this.debugprocess) {
4849
return;
4950
}
5051

5152
this.watchMode = watchMode;
53+
this.watchAll = watchAll;
5254

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

5759
const args = ['--json', '--useStderr', outputArg, this.outputPath];
5860
if (this.watchMode) {
59-
args.push('--watch');
61+
args.push(this.watchAll ? '--watchAll' : '--watch');
6062
}
6163
if (this.options.testNamePattern) {
6264
args.push('--testNamePattern', this.options.testNamePattern);

packages/jest-editor-support/src/__tests__/runner.test.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ describe('Runner', () => {
4848
expect(sut.watchMode).not.toBeDefined();
4949
});
5050

51+
it('does not set watchAll', () => {
52+
const workspace: any = {};
53+
const sut = new Runner(workspace);
54+
55+
expect(sut.watchAll).not.toBeDefined();
56+
});
57+
5158
it('sets the output filepath', () => {
5259
tmpdir.mockReturnValueOnce('tmpdir');
5360

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

117+
it('sets watchAll', () => {
118+
const watchMode = true;
119+
const watchAll = true;
120+
121+
const workspace: any = {};
122+
const sut = new Runner(workspace);
123+
sut.start(watchMode, watchAll);
124+
125+
expect(sut.watchMode).toBe(watchMode);
126+
expect(sut.watchAll).toBe(watchAll);
127+
});
128+
110129
it('calls createProcess', () => {
111130
const workspace: any = {};
112131
const sut = new Runner(workspace);

0 commit comments

Comments
 (0)