import * as t from 'io-ts' ; import { PathReporter } from 'io-ts/lib/PathReporter' ; import { matcherHint , printExpected , printReceived } from 'jest-matcher-utils' ; import { Either } from 'fp-ts/lib/Either' ; import { containsMatches } from '../../predicates' ; import { pipe } from 'fp-ts/lib/pipeable' ; const passMessage = ( received , expected ) => ( ) => matcherHint ( '.not.toBeLeftWithErrorsMatching' , 'received' , 'expectedLeftErrorsMatching' ) + '\n\n' + 'Expected Either not to be left with errors matching:\n' + `  ${ printExpected ( expected ) }` + '\n\n' + printReceived ( PathReporter . report ( received ) ) ; const failMessage = ( received , expected ) => ( ) => matcherHint ( '.toBeLeftWithErrorsMatching' , 'received' , 'expectedLeftErrorsMatching' ) + '\n\n' + 'Expected Either to be left with errors matching:\n' + `  ${ printExpected ( expected ) }` + '\n\n' + printReceived ( PathReporter . report ( received ) ) ; remarks example export const toBeLeftWithErrorsMatching = ( received , expected ) : any => { const pass = pipe ( received , PathReporter . report , containsMatches ( expected ) ) ; return { pass , message : pass ? passMessage ( received , expected ) : failMessage ( received , expected ) , } ; } ;