import '@testing-library/jest-dom/extend-expect' ; import 'jest-svelte-events/extend-expect' ; import type { SvelteComponent } from 'svelte/internal' ; let frame = 1000 / 60 ; let amountOfFrames = 2 ; let formatter = new Intl . NumberFormat ( 'en' ) ; expect . extend ( { toBeWithinRenderFrame ( actual , expected ) { let min = expected - frame * amountOfFrames ; let max = expected + frame * amountOfFrames ; let pass = actual >= min && actual <= max ; return { message : pass ? ( ) => { return `expected ${ actual } not to be within range of a frame ${ formatter . format ( min ) } - ${ formatter . format ( max ) }` ; } : ( ) => { return `expected ${ actual } not to be within range of a frame ${ formatter . format ( min ) } - ${ formatter . format ( max ) }` ; } , pass } ; } } ) ; declare global { namespace jest { interface Matchers < R , T > { toHaveFiredEvent ( event ) : R ; toHaveFiredEvents ( events ) : R ; toHaveFiredEventsInOrder ( events ) : R ; toHaveFiredEventTimes ( event , times ) : R ; toHaveFiredEventWith ( event , payload ) : R ; toHaveFiredLastEventWith ( payload ) : R ; toHaveFiredNthEventWith ( n , payload ) : R ; } } const listen ; }