This library aims to provide custom assertions for Luxon with Jest runner
yarn add --dev luxon-jest-matchers
In your jest.config.js :
setupFilesAfterEnv: ['luxon-jest-matchers']
You can add this at the beginning of your tests or in a definition file (.d.ts) you include in your tsconfig.json :
import 'luxon-jest-matchers';
- toEqualDateTime(date: DateTime)
- toBeStrictlyBeforeDateTime(date: DateTime)
- toBeBeforeDateTime(date: DateTime)
- toBeStrictlyAfterDateTime(date: DateTime)
- toBeAfterDateTime(date: DateTime)
- toBeValidDateTime()
- toBeSameDateAs(date: DateTime)
- toEqualDuration(duration: Duration)
- toEqualDurationAs(duration: Duration, unit: DurationUnit)
- toBeValidDuration()
- toEqualInterval(interval: Interval)
- toEngulfInterval(interval: Interval)
- toContainDateTime(date: DateTime)
- toBeValidInterval()