Skip to content

Commit

Permalink
fixed autoplay issue
Browse files Browse the repository at this point in the history
  • Loading branch information
inc-man committed Nov 28, 2024
1 parent 51a3d75 commit 7a14b4e
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions e2e/utils/carousel-autoplay.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ import { type Page } from '@playwright/test';

export async function disableCarouselAutoplay(page: Page) {
await page.addInitScript(() => {
(window.setInterval as any) = (
handler: TimerHandler,
timeout?: number,
...args: any[]
): number => {
console.warn('setInterval has been disabled to prevent carousel autoplay.');
return 0;
const originalSetInterval = setInterval
const mockSetInterval = (handler: TimerHandler, timeout?: number, ...args: unknown[]): number => {
console.warn('setInterval has been disabled to prevent carousel autoplay.');
return 0;
};

mockSetInterval.__promisify__ = originalSetInterval.__promisify__

window.setInterval = mockSetInterval as typeof setInterval;
});
}
}

0 comments on commit 7a14b4e

Please sign in to comment.