Skip to content

Commit 27cb54e

Browse files
committed
fix(reporters): write buffered stdout/stderr on process exit
1 parent f1babdc commit 27cb54e

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

packages/vitest/src/node/reporters/renderers/windowedRenderer.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type { Writable } from 'node:stream'
22
import type { Vitest } from '../../core'
33
import { stripVTControlCharacters } from 'node:util'
44
import restoreCursor from 'restore-cursor'
5+
import { onExit } from 'signal-exit'
56

67
const DEFAULT_RENDER_INTERVAL = 16
78

@@ -54,6 +55,9 @@ export class WindowRenderer {
5455
restoreCursor()
5556
this.write(HIDE_CURSOR, 'output')
5657

58+
// Write buffered content on unexpected exits, e.g. direct `process.exit()` calls
59+
onExit(() => this.flushBuffer())
60+
5761
this.start()
5862
}
5963

0 commit comments

Comments
 (0)