Skip to content

Commit 86b60bb

Browse files
authored
Mock prototype in unit test to prevent relative date breaking snapshots. (#73531)
1 parent f61df05 commit 86b60bb

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

x-pack/plugins/uptime/public/components/common/charts/__tests__/ping_histogram.test.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,13 @@
77
import React from 'react';
88
import { PingHistogramComponent, PingHistogramComponentProps } from '../ping_histogram';
99
import { renderWithRouter, shallowWithRouter, MountWithReduxProvider } from '../../../../lib';
10+
import moment from 'moment';
1011

1112
describe('PingHistogram component', () => {
13+
beforeAll(() => {
14+
moment.prototype.fromNow = jest.fn(() => 'a year ago');
15+
});
16+
1217
const props: PingHistogramComponentProps = {
1318
absoluteStartDate: 1548697920000,
1419
absoluteEndDate: 1548700920000,

0 commit comments

Comments
 (0)