Created
January 11, 2024 14:18
-
-
Save giathinh910/329b22fcd6d1a29c04e1fc6ad6f4370c to your computer and use it in GitHub Desktop.
Jest Dayjs custom matchers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Dayjs, OpUnitType } from 'dayjs'; | |
const isEqualTime = (expected: Dayjs, unit: OpUnitType = 'ms') => ({ | |
$$typeof: Symbol.for('jest.asymmetricMatcher'), | |
asymmetricMatch: (actual: Dayjs) => expected.isSame(actual, unit), | |
toAsymmetricMatcher: () => 'Dayjs<' + expected.toISOString() + '>', | |
}); | |
export default isEqualTime; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment