fetch-spy
v1.3.0
Published
Spy fetch request in tests.
Downloads
8
Readme
fetch-spy
simple fetch mocking module.
Usage
import * as FetchSpy from 'fetch-spy';
describe('test', () => {
beforeEach(() => {
FetchSpy.reset()
})
it('should work' () => {
const spy = FetchSpy.spy({ method: 'GET', pathname: '/foo/bar/*' }, new Response(JSON.stringify({
foo: 'bar'
}), { status: 200 }));
await complexFunction();
expect(spy.calls).toMatchSnapshot([{
url: '/foo/bar'
}]);
})
})