jefflau / jest-fetch-mock

Jest mock for fetch
MIT License
883 stars 116 forks source link

Refactor readme #144

Open jefflau opened 4 years ago

jefflau commented 4 years ago

Currently the documentation for the new conditional mocking is quite a wall of code. I would like to take some time to simplify it so it is easier for new users to get the hang of our new features and not create issues for features that already exists.

@yinzara Maybe we can discuss how we can break up the last sections. One thing I can immediately think of is to remove:

 const expectMocked = async (uri, response = mockedDefaultResponse) => {
    return expect(request(uri)).resolves.toEqual(response)
  }
  const expectUnmocked = async uri => {
    return expect(request(uri)).resolves.toEqual(realResponse)
  }

This is a great abstraction for writing tests for our library, but not so great for a new user having to see our test abstractions for jest-fetch-mock.

Another we can do is break up each example with a title and a bit of an explanation on how/why you would use each example. As a user I would probably want to see an explanation of what's happening in the code example so I can understand why I would use it in this particular situation.