Skip to content

Commit 483e52a

Browse files
authored
test(demo): replace 3s real-time wait with fake timers in slow-validation test (#2356)
1 parent 071edfc commit 483e52a

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

‎packages/demo/demo.vitest.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,20 @@ describe('@inquirer/demo E2E tests', () => {
112112
`"? (Slow validation) provide a number: 42"`,
113113
);
114114

115+
// Use fake timers to skip the 3s validation delay in the demo
116+
vi.useFakeTimers({ toFake: ['setTimeout'] });
115117
screen.keypress('enter');
118+
await vi.runAllTimersAsync();
119+
vi.useRealTimers();
120+
116121
await demo;
117122

118123
expect(await screen.getFullOutput()).toMatchInlineSnapshot(`
119124
"✔ What's your favorite food? Pizza
120125
✔ Enter an hex color? fff
121126
✔ (Slow validation) provide a number: 42"
122127
`);
123-
}, 10000);
128+
});
124129
});
125130

126131
describe('screen.keypress()', () => {

0 commit comments

Comments
 (0)