1- // @ts -ignore
2- import { toMatchImageSnapshot as toMatchImageSnapshotBase } from 'jest-image-snapshot'
3- // @ts -ignore
1+ import {
2+ MatchImageSnapshotOptions ,
3+ toMatchImageSnapshot as toMatchImageSnapshotBase ,
4+ } from 'jest-image-snapshot'
45import { toMatchSnapshot } from 'jest-snapshot'
56import { a11ySnapshot , domSnapshot , imageSnapshot } from '.'
67import ComponentElement from './types/component-element'
78
9+ declare global {
10+ // eslint-disable-next-line @typescript-eslint/no-namespace
11+ namespace jest {
12+ interface Matchers < R > {
13+ toMatchA11ySnapshot ( ) : R
14+ toMatchDomSnapshot ( ) : R
15+ toMatchImageSnapshot ( options : MatchImageSnapshotOptions ) : R
16+ }
17+ }
18+ }
19+
820const extendExpect = ( ) => {
9- // @ts -ignore
1021 expect . extend ( {
1122 async toMatchA11ySnapshot ( received : ComponentElement ) {
1223 return toMatchSnapshot . call (
@@ -17,7 +28,6 @@ const extendExpect = () => {
1728 } ,
1829 } )
1930
20- // @ts -ignore
2131 expect . extend ( {
2232 async toMatchDomSnapshot ( received : ComponentElement ) {
2333 return toMatchSnapshot . call (
@@ -28,10 +38,12 @@ const extendExpect = () => {
2838 } ,
2939 } )
3040
31- // @ts -ignore
3241 expect . extend ( {
33- async toMatchImageSnapshot ( received : ComponentElement , options : any ) {
34- return toMatchImageSnapshotBase . call (
42+ async toMatchImageSnapshot (
43+ received : ComponentElement ,
44+ options : MatchImageSnapshotOptions ,
45+ ) {
46+ return ( toMatchImageSnapshotBase as any ) . call (
3547 this as any ,
3648 await imageSnapshot ( received ) ,
3749 options ,
0 commit comments