Skip to content

Commit c91c357

Browse files
author
Mohammod Al Amin Ashik
committed
test: fix Toast test timeout with userEvent and fake timers
Resolved timeout issue by temporarily switching to real timers during user interaction test, preventing conflicts between fake timers and userEvent's async operations.
1 parent 00fd794 commit c91c357

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

Cargo.lock

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/ts/components/Toast.test.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ describe('Toast', () => {
6363
});
6464

6565
it('should call onClose when close button is clicked', async () => {
66-
const user = userEvent.setup({ delay: null });
66+
vi.useRealTimers(); // Use real timers for user interaction
67+
const user = userEvent.setup();
6768
const onClose = vi.fn();
6869

6970
render(
@@ -80,6 +81,7 @@ describe('Toast', () => {
8081
await user.click(closeButton);
8182

8283
expect(onClose).toHaveBeenCalledWith('test-1');
84+
vi.useFakeTimers(); // Restore fake timers for other tests
8385
});
8486

8587
it('should auto-dismiss after duration', () => {

0 commit comments

Comments
 (0)