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 98d1d6f
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
Expand Up @@ -44,6 +44,7 @@
"@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",
"mock-fs": "^4.4.1",
"strip-ansi": "^6.0.0"
Expand Down
6 changes: 3 additions & 3 deletions packages/jest-reporters/src/DefaultReporter.ts
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
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
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 98d1d6f

Please sign in to comment.