Mocking dayjs extend
问题 In my code that needs testing I use import dayjs from 'dayjs'; import utc from 'dayjs/plugin/utc'; dayjs.extend(utc); dayjs().add(15, 'minute') In my test I need to mock dayjs in order to always have the same date when comparing snapshots in jest so I did jest.mock('dayjs', () => jest.fn((...args) => jest.requireActual('dayjs')( args.filter((arg) => arg).length > 0 ? args : '2020-08-12' ) ) ); It fails with TypeError: _dayjs.default.extend is not a function Unfortunately similar questions on