Skip to content

Commit 5b427f1

Browse files
committed
fix: flaky test
1 parent a318aa4 commit 5b427f1

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

test/subCommands.test.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { expect, test } from 'vitest';
22
import { runp } from '../src';
3-
import { TestTerminal } from './_helpers';
3+
import { poll, TestTerminal } from './_helpers';
4+
import { setTimeout } from 'timers/promises';
45

56
test('subCommands', async () => {
67
const term = new TestTerminal({ cols: 30, rows: 20 });
@@ -27,7 +28,9 @@ test('subCommands', async () => {
2728
linearOutput: true,
2829
});
2930

30-
expect(term.getBuffer()).toMatchInlineSnapshot(`
31+
await poll(
32+
() =>
33+
expect(term.getBuffer()).toMatchInlineSnapshot(`
3134
[
3235
" ",
3336
"-- [subCommand 1] -> ",
@@ -50,5 +53,7 @@ test('subCommands', async () => {
5053
" ",
5154
" ",
5255
]
53-
`);
56+
`),
57+
1000,
58+
);
5459
});

0 commit comments

Comments
 (0)