Skip to content

Commit

Permalink
Ensure verbose mode prints output synchronously
Browse files Browse the repository at this point in the history
  • Loading branch information
conartist6 committed Feb 4, 2021
1 parent 98ed700 commit ef929ba
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/jest-reporters/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"@jest/test-result": "^27.0.0-next.1",
"@jest/transform": "^27.0.0-next.2",
"@jest/types": "^27.0.0-next.1",
"@types/node": "*",
"chalk": "^4.0.0",
"collect-v8-coverage": "^1.0.0",
"exit": "^0.1.2",
Expand Down
6 changes: 3 additions & 3 deletions packages/jest-reporters/src/DefaultReporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ export default class DefaultReporter extends BaseReporter {
this._err = process.stderr.write.bind(process.stderr);
this._status = new Status();
this._bufferedOutput = new Set();
this._wrapStdio(process.stdout);
this._wrapStdio(process.stderr);
this.__wrapStdio(process.stdout);
this.__wrapStdio(process.stderr);
this._status.onChange(() => {
this._clearStatus();
this._printStatus();
});
}

private _wrapStdio(stream: NodeJS.WritableStream | NodeJS.WriteStream) {
protected __wrapStdio(stream: NodeJS.WritableStream | NodeJS.WriteStream) {
const originalWrite = stream.write;

let buffer: Array<string> = [];
Expand Down
5 changes: 5 additions & 0 deletions packages/jest-reporters/src/VerboseReporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ export default class VerboseReporter extends DefaultReporter {
this._globalConfig = globalConfig;
}

// Verbose mode is for debugging. Buffering of output is undesirable.
// See https://github.com/facebook/jest/issues/8208
protected __wrapStdio() {
}

static filterTestResults(
testResults: Array<AssertionResult>,
): Array<AssertionResult> {
Expand Down
1 change: 1 addition & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1990,6 +1990,7 @@ __metadata:
"@types/istanbul-lib-report": ^3.0.0
"@types/istanbul-lib-source-maps": ^4.0.0
"@types/istanbul-reports": ^3.0.0
"@types/node": "*"
"@types/node-notifier": ^8.0.0
chalk: ^4.0.0
collect-v8-coverage: ^1.0.0
Expand Down

0 comments on commit ef929ba

Please sign in to comment.