You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Following the implementation of user defined matchers I'm now thinking of what would be a good way to allow others to define packages that can be plugged in to fetch-mock. I would really like to put together (or have somebody else put together) a plugin to make dealing with graphql easier
Criteria
should be possible to plug in to fetch-mock or fetch-mock-jest
maximum of 1 function call for the end user to hook up fetch-mock to the package
should support adding other kinds of extensions (e.g. shorthands for preconfigured mocks)
Options
exports an extended version of fetch-mock, and is intended to be imported instead of fetch-mock
extends fetch-mock, but exports nothing - fetch-mock is still the main thing to be required by the user
exports a function which is passed an instance of fetch-mock, and which adds the extensions
exports a thing which is passed into a .use() method of fetch-mock
Discussion
Struggles to meet criteria 1 (at least, not without being confusing)
Lacks transparency over what's going on
This delegates definition of patterns to user land - they could call their functions whatever they like, have them meddle with fech-mock in all sorts of unpredictable ways
Preferred option at this stage. Gives fetch-mock control over what extensions are added and how to add them, and the user full control over knowing when they've been added
Proposal
Investigate option 4, in particular
What does an interface for defining a shortcut method look like
What does an interface for defining a new option look like
What type of thing should .use() accept
The text was updated successfully, but these errors were encountered:
Following the implementation of user defined matchers I'm now thinking of what would be a good way to allow others to define packages that can be plugged in to fetch-mock. I would really like to put together (or have somebody else put together) a plugin to make dealing with graphql easier
Criteria
Options
.use()
method of fetch-mockDiscussion
Proposal
Investigate option 4, in particular
.use()
acceptThe text was updated successfully, but these errors were encountered: