mswjs / msw

Industry standard API mocking for JavaScript.
https://mswjs.io
MIT License
15.98k stars 520 forks source link

Compare to Service Mocker #65

Closed kettanaito closed 4 years ago

kettanaito commented 4 years ago

There is a Service Mocker library that also utilizes Service Workers for the purpose of API mocking. I'd like to introduce a comparison section to the MSW documentation that highlights the difference between two libraries, helping developers to choose what suits them best.

Please, if you are an active user of Service Mocker feel free to provide suggestions or edits to the comparison table below.

Comparison

Setup

Service Mocker MSW
Has client and server parts. Has only client part.
Seems like requires to set Service-Worker-Allowed header to register a worker on a path different than root. Requires to place the worker file in the public dir of your app.

I'd say that you need less setup code to start with MSW, making the adoption process faster. The substantial flaw is that MSW requires to place the mockServiceWorker.js in your public directory.

Workflow

Service Mocker MSW
Adopts Express API in its entirety. Seamless usage for Express users. Adopts Express API partially. Favors functional composition. Has custom ctx utilities for more efficient mocking.

Internals

MSW

Client -- request --> ServiceWorker -- serialize --> Client (MSW) -- get response from schema --> ServiceWorker --> `respondWith()`
kettanaito commented 4 years ago

I've tried to put up the first difference I spotted when reading the docs. I have not actually used Service Mocker, so my conclusion may be incomplete or irrelevant. I'll try to use that library and update this comparison with more objective points.

kettanaito commented 4 years ago

I've performed a comparison between the two solutions and will publish it as a part of updated website and docs. Closing this to prevent confusion.