Mock prototype in unit test to prevent relative date breaking snapshots. (#73531)

This commit is contained in:
Justin Kambic 2020-07-28 14:52:12 -04:00 committed by GitHub
parent f61df05772
commit 86b60bbc63
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -7,8 +7,13 @@
import React from 'react';
import { PingHistogramComponent, PingHistogramComponentProps } from '../ping_histogram';
import { renderWithRouter, shallowWithRouter, MountWithReduxProvider } from '../../../../lib';
import moment from 'moment';
describe('PingHistogram component', () => {
beforeAll(() => {
moment.prototype.fromNow = jest.fn(() => 'a year ago');
});
const props: PingHistogramComponentProps = {
absoluteStartDate: 1548697920000,
absoluteEndDate: 1548700920000,