diff --git a/packages/react-navigation/jest-setup.js b/packages/react-navigation/jest-setup.js new file mode 100644 index 00000000..37d82708 --- /dev/null +++ b/packages/react-navigation/jest-setup.js @@ -0,0 +1,28 @@ +/** + * @flow + * eslint-env jest + */ + +// See https://github.com/facebook/jest/issues/2208 +jest.mock('Linking', () => ({ + addEventListener: jest.fn(), + removeEventListener: jest.fn(), + openURL: jest.fn(), + canOpenURL: jest.fn(), + getInitialURL: jest + .fn() + .mockImplementation((value: string) => Promise.resolve(value)), +})); + +// See https://github.com/facebook/react-native/issues/11659 +jest.mock('ScrollView', () => { + // $FlowExpectedError + const RealComponent = require.requireActual('ScrollView'); + class ScrollView extends RealComponent { + scrollTo = () => {}; + } + return ScrollView; +}); + +// $FlowExpectedError +Date.now = jest.fn(() => 0);