fetch-spy
TypeScript icon, indicating that this package has built-in type declarations

1.3.0 • Public • Published

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'
    }]);
  })
})

Readme

Keywords

Package Sidebar

Install

npm i fetch-spy

Weekly Downloads

2

Version

1.3.0

License

MIT

Unpacked Size

42.8 kB

Total Files

9

Last publish

Collaborators

  • hrsh7th