我想要类似以下的东西(实际上有效......):
import { NativeModules } from 'react-native';
import PushNotifications from '../../app/platform/PushNotificationSupport';
const mockRNA = jest.requireMock('react-native');
jest.mock('react-native', () => {
return {
default: mockRNA.default,
NativeModules: {
...mockRNA.NativeModules,
NativePushNotifications: {
setTokenHandler: jest.fn(),
},
},
};
});
当然,上面的代码实际上并不起作用。我本质上想建立在现有的react-native
模拟之上。