-
-
Notifications
You must be signed in to change notification settings - Fork 215
Open
Description
Hello, I have been trying to follow the React Native integration documents and assorted Github issues but I cannot get the integration working. I'd really love to as I want to run MSW for my E2E tests to mock the backend. I have verified MirageJS works as intended but we already use MSW for unit tests so want to try and get it working.
React Native version: 0.77.2
MSW version: 2.10.4
Any help would be appreciated.
Code samples:
// msw.polyfills.js
import 'fast-text-encoding';
import 'react-native-url-polyfill/auto';
// src/mocks/server.js
import { setupServer } from 'msw/native';
import { accountHandlers } from '../test/servers/msw/handlers/ecomm/account';
const handlers = [...accountHandlers];
export const server = setupServer(...handlers);
// index.js
/**
* @format
*/
import 'intl-pluralrules';
import { AppRegistry } from 'react-native';
import 'react-native-gesture-handler';
import { name as appName } from './app.json';
import App from './src/App';
if (__DEV__) {
import('./reactotron.config')
// eslint-disable-next-line no-console
.then(() => console.log('Reactotron Configured'))
// eslint-disable-next-line no-console
.catch(() => console.log('Reactotron failed to initialize'));
}
async function enableMocking() {
if (!__DEV__) {
return;
}
await import('./msw.polyfills');
const { server } = await import('./src/mocks/server');
server.listen();
}
enableMocking().then(() => {
AppRegistry.registerComponent(appName, () => App);
});
Errors encountered:

sidorchukandrew
Metadata
Metadata
Assignees
Labels
No labels