Skip to content

Commit

Permalink
mock more node_modules
Browse files Browse the repository at this point in the history
  • Loading branch information
marcaaron committed Oct 24, 2022
1 parent 733f8cf commit 48d6a9c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 17 deletions.
1 change: 1 addition & 0 deletions __mocks__/react-native-blob-util.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default {};
7 changes: 7 additions & 0 deletions __mocks__/react-native-reanimated.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// This mock is required as per setup instructions for react-navigation testing
// https://reactnavigation.org/docs/testing/#mocking-native-modules

const Reanimated = require('react-native-reanimated/mock');

Reanimated.default.call = () => {};
module.exports = Reanimated;
11 changes: 1 addition & 10 deletions jest/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,9 @@ import _ from 'underscore';

require('react-native-reanimated/lib/reanimated2/jestUtils').setUpTests();

jest.mock('react-native-blob-util', () => ({}));

// These two mocks are required as per setup instructions for react-navigation testing
// This mock is required as per setup instructions for react-navigation testing
// https://reactnavigation.org/docs/testing/#mocking-native-modules
jest.mock('react-native/Libraries/Animated/NativeAnimatedHelper');
jest.mock('react-native-reanimated', () => {
const Reanimated = require('react-native-reanimated/mock');
Reanimated.default.call = () => {};
return Reanimated;
});

jest.mock('react-native-blob-util', () => ({}));

// Turn off the console logs for timing events. They are not relevant for unit tests and create a lot of noise
jest.spyOn(console, 'debug').mockImplementation((...params) => {
Expand Down
7 changes: 0 additions & 7 deletions tests/unit/NetworkTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,6 @@ import * as SequentialQueue from '../../src/libs/Network/SequentialQueue';
import * as MainQueue from '../../src/libs/Network/MainQueue';
import * as Request from '../../src/libs/Request';

// Set up manual mocks for methods used in the actions so our test does not fail.
jest.mock('../../src/libs/Notification/PushNotification', () => ({
// There is no need for a jest.fn() since we don't need to make assertions against it.
register: () => {},
deregister: () => {},
}));

jest.useFakeTimers();

Onyx.init({
Expand Down

0 comments on commit 48d6a9c

Please sign in to comment.