Skip to content

Commit

Permalink
test: Replace require.requireActual and require.requireMock (#18894)
Browse files Browse the repository at this point in the history
  • Loading branch information
scttcper committed May 19, 2020
1 parent 927ac4b commit 01dd994
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions tests/js/setup.js
Expand Up @@ -53,7 +53,7 @@ jest.mock('app/utils/domId');
jest.mock('app/utils/withOrganization');
jest.mock('scroll-to-element', () => jest.fn());
jest.mock('react-router', () => {
const ReactRouter = require.requireActual('react-router');
const ReactRouter = jest.requireActual('react-router');
return {
IndexRedirect: ReactRouter.IndexRedirect,
IndexRoute: ReactRouter.IndexRoute,
Expand All @@ -75,7 +75,7 @@ jest.mock('react-lazyload', () => {
});

jest.mock('react-virtualized', () => {
const ActualReactVirtualized = require.requireActual('react-virtualized');
const ActualReactVirtualized = jest.requireActual('react-virtualized');
return {
...ActualReactVirtualized,
AutoSizer: ({children}) => children({width: 100, height: 100}),
Expand All @@ -97,7 +97,7 @@ jest.mock('echarts-for-react/lib/core', () => {
});

jest.mock('@sentry/browser', () => {
const SentryBrowser = require.requireActual('@sentry/browser');
const SentryBrowser = jest.requireActual('@sentry/browser');
return {
init: jest.fn(),
configureScope: jest.fn(),
Expand Down Expand Up @@ -148,7 +148,7 @@ window.$ = window.jQuery = jQuery;
window.scrollTo = jest.fn();

// This is very commonly used, so expose it globally.
window.MockApiClient = require.requireMock('app/api').Client;
window.MockApiClient = jest.requireMock('app/api').Client;

window.TestStubs = {
// react-router's 'router' context
Expand Down
2 changes: 1 addition & 1 deletion tests/js/spec/components/charts/components/xAxis.spec.jsx
@@ -1,7 +1,7 @@
import XAxis from 'app/components/charts/components/xAxis';

jest.mock('moment', () => {
const moment = require.requireActual('moment-timezone');
const moment = jest.requireActual('moment-timezone');
moment.tz.setDefault('America/Los_Angeles'); // Whatever timezone you want
return moment;
});
Expand Down

0 comments on commit 01dd994

Please sign in to comment.