Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 18 additions & 9 deletions packages-internal/test-utils/src/createRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,15 @@ function createClock(
vi.setSystemTime(config);
}
});

afterEach(async () => {
if (vi.isFakeTimers()) {
await rtlAct(async () => {
vi.runOnlyPendingTimers();
});
vi.useRealTimers();
}
});
} else {
beforeEach(() => {
if (config) {
Expand All @@ -229,15 +238,6 @@ function createClock(
});
}

afterEach(async () => {
if (vi.isFakeTimers()) {
await rtlAct(async () => {
vi.runOnlyPendingTimers();
});
vi.useRealTimers();
}
});

return {
withFakeTimers: () => {
if (vi.isFakeTimers()) {
Expand Down Expand Up @@ -266,6 +266,15 @@ function createClock(
vi.setSystemTime(config);
}
});

afterEach(async () => {
if (vi.isFakeTimers()) {
await rtlAct(async () => {
vi.runOnlyPendingTimers();
});
vi.useRealTimers();
}
});
},
runToLast: () => {
rtlAct(() => {
Expand Down
Loading