Spaces:
Running
Running
File size: 879 Bytes
d4b85c0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
import { FetchInterceptor } from '@mswjs/interceptors/fetch'
import { XMLHttpRequestInterceptor } from '@mswjs/interceptors/XMLHttpRequest'
import type { RequestHandler } from '~/core/handlers/RequestHandler'
import { SetupServerCommonApi } from '../node/SetupServerCommonApi'
/**
* Sets up a requests interception in React Native with the given request handlers.
* @param {RequestHandler[]} handlers List of request handlers.
*
* @see {@link https://mswjs.io/docs/api/setup-server `setupServer()` API reference}
*/
export function setupServer(
...handlers: Array<RequestHandler>
): SetupServerCommonApi {
// Provision request interception via patching the `XMLHttpRequest` class only
// in React Native. There is no `http`/`https` modules in that environment.
return new SetupServerCommonApi(
[FetchInterceptor, XMLHttpRequestInterceptor],
handlers,
)
}
|