Rename "composeMocks" to better describe what it does
See original GitHub issueIs your feature request related to a problem? Please describe.
I find it confusing that composeMocks()
function composes request handlers, and not mocks.
Describe the solution you’d like
I think renaming composeMocks()
function to composeHandlers()
would provide a more domain-driven name, and won’t confuse the users.
- const { start } = composeMocks(...)
+ const { start } = composeHandlers(...)
Benefits of the change
- Aligned with the internal vocabulary
- Function does exactly what it’s called after
Drawbacks of the change
- Longer to write
- Not straight intuitive if you don’t know the library’s glossary
Alternatives to consider
I was also thinking about simply naming it compose()
, but I’m afraid this will clash with the similar functional composition utility that is often called compose()
. Also, composeMocks()
is not the traditional compose function per-say, as it’s logic is specific to MSW.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:15 (12 by maintainers)
Top Results From Across the Web
Untitled
Define purging storage, Pastor luna chamame maceta, Cherish the ladies an irish ... Best amp for headphone practice, Raonsims hair 46, Surheide bremerhaven, ......
Read more >The msw from mswjs - Mock Service Worker
Mock Service Worker (MSW) is a seamless REST/GraphQL API mocking library for browser and Node.js. ... Rename "composeMocks" to better describe what it...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
As MSW will eventually support mocking in non-browser environments, I think that such initializer functions like
composeMocks()
should clearly describe what are they initializing.I suggest the following API:
useWorker()
Uses a Service Worker with the given request handlers.
useServer()
Stubs an XHR communication with the given request handlers, thus, mimicking a server.