@mocat/interceptor
v0.3.0
Published
Interceptor for Mocat
Downloads
3
Readme
Mocat Interceptor
Intro
The part of Mocat which is used to interceptor http request.
Usage
Install dependencies:
yarn add --dev @mocat/interceptor
Then
import { eventEmitter, setupFetch, setupXHR } from '@mocat/interceptor'
// proxy http request
const resetFetch = setupFetch()
const resetXHR = setupXHR()
eventEmitter.onAny((event, value) => console.log(event, value))
// reset
resetFetch()
resetXHR()
Credits
The implementation of this module is power by the following prior art in the JavaScript ecosystem:
Caveats
@mocat/interceptor
will replaceswindow.fetch
andwindow.XMLHttpRequest
with a proxy that Mocat can spy on and stub.