Skip to content

Commit 8c4adec

Browse files
Bill LeoutsakosBill Leoutsakos
authored andcommitted
fix(test): settle OTP timers before DOM teardown
1 parent 81fbe50 commit 8c4adec

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

‎packages/emcn/src/components/input-otp/input-otp.test.tsx‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ let root: Root
1010
let host: HTMLDivElement
1111

1212
beforeEach(() => {
13+
vi.useFakeTimers()
1314
;(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true
1415
vi.stubGlobal(
1516
'ResizeObserver',
@@ -25,9 +26,12 @@ beforeEach(() => {
2526
})
2627

2728
afterEach(() => {
28-
act(() => root.unmount())
29+
act(() => {
30+
root.unmount()
31+
vi.runOnlyPendingTimers()
32+
})
2933
host.remove()
30-
vi.unstubAllGlobals()
34+
vi.useRealTimers()
3135
})
3236

3337
function renderOtp(invalid: boolean) {

0 commit comments

Comments
 (0)