I\'m using Enzyme with enzyme-to-json to do Jest snapshot testing of my React components. I\'m testing shallow snapshots of a DateRange component that renders a
If you're using new Date() constructor instead of Date.now you can do like below:
const RealDate = Date;
beforeEach(() => {
// @ts-ignore
global.Date = class extends RealDate {
constructor() {
super();
return new RealDate("2016");
}
};
})
afterEach(() => {
global.Date = RealDate;
});
This issue is a must visit if you're here.