Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

fix(test-runner): make it compatible when running as a sub-process (#7298)

Max Schmitt908ad6921f38
diff --git a/src/test/runner.ts b/src/test/runner.ts
index 591b9ddbd5..18e22f8801 100644
--- a/src/test/runner.ts
+++ b/src/test/runner.ts
@@ -109,14 +109,9 @@ export class Runner {
async _flushOutput() {
// Calling process.exit() might truncate large stdout/stderr output.
// See https://github.com/nodejs/node/issues/6456.
- //
- // We can use writableNeedDrain to workaround this, but it is only available
- // since node v15.2.0.
- // See https://nodejs.org/api/stream.html#stream_writable_writableneeddrain.
- if ((process.stdout as any).writableNeedDrain)
- await new Promise(f => process.stdout.on('drain', f));
- if ((process.stderr as any).writableNeedDrain)
- await new Promise(f => process.stderr.on('drain', f));
+ // See https://github.com/nodejs/node/issues/12921
+ await new Promise<void>(resolve => process.stdout.write('', () => resolve()));
+ await new Promise<void>(resolve => process.stderr.write('', () => resolve()));
}
async _run(list: boolean, testFileReFilters: FilePatternFilter[], projectName?: string): Promise<RunResult> {