import { isSameYear } from 'date-fns' ; import { checkDate , deriveRelativeDateMessage } from './utils' ; declare global { namespace jest { interface Matchers < R , T > { param { Date } date example toBeSameYearAs ( date ) : R ; } } } export function toBeSameYearAs ( this , received , expected ) { checkDate ( 'received' , received , toBeSameYearAs , { invert : this . isNot } ) ; checkDate ( 'expected' , expected , toBeSameYearAs , { invert : this . isNot } ) ; const messageContext = { name : toBeSameYearAs . name , expected , received , invert : this . isNot , } ; return { pass : isSameYear ( received , expected ) , message : ( ) => deriveRelativeDateMessage ( messageContext ) , } ; }