I\'m unable to mock moment()
or moment().format
functions. I have states where, currentDateMoment
and currentDateFormatted
ar
I was still getting some errors because I was using moment-timezone, too. So, here's what I did to fix that:
let diffMins = updateThreshold + 1;
jest.mock('moment', () => {
const mMoment = {
diff: jest.fn(() => diffMins),
};
const fn = jest.fn(() => mMoment);
fn.version = '2.24';
fn.tz = jest.fn();
fn.fn = jest.fn();
return fn;
});