Comments (3)
Before diving into the implementation detail, I'd like to point out the main use cases of this library we can see now, which I think will help to polish our public API.
As far as I can see, there exists two main purposes of mock server:
1. Daily development
Mostly, frontend programmers would use a test backend in daily development. But sometimes when backend is not ready, frontend programmers would likely write some mock API response.
Besides, the mock API responses even can be reused to do testing(the following second purpose).
2. Testing
This is big one. With service-mocker
, we can nearly test our app with least mock. But there exist some limitations:
- tests must be run on browser(like
karma
, but notjest
) - browser supports are poor now
- we can't test compatibility of our app now
There must exists more use cases I haven't covered above. As for the main two use cases, I think service-mocker
need:
- client side code is simple (even no client side code)
- easy to write mock server code.
- I think it is meaningless for developers to set up a full-featured mock server. Developers should write mock server code easily like nock, but rather than a full-featured express app.
- As a lib, maybe we can provide the power to write a full-featured server app. But I think the easy way should implemented first.
@idiotWu these are some of my thoughts about service-mocker
, what's your opinions?
from service-mocker.
@vincentbel yeah I agree.
Actually, I have been thinking about the second point - testing - these days and all the conclusions lead to one thing: patch up XMLHttpRequest
. As long as we patched xhr, we can:
- Full compatibility.
- Be able to run tests with something like jsdom (or any environment that includes
XMLHttpRequest
constructor).
And as for the daily devs, I think it would be much simpler to run a script in browsers than set up a server - for which you'll have to write some manuals for newcomers in your team 😢
In my thoughts, this lib should be a minimalist one. There's no need to create an express in browsers, the client-side API includes a register method and a storage service only, and a get/post/any
router plus storage service for server-side API.
What confusing me now is the request/response
interfaces. I have no idea how far we should go.
PS: we can even remove storage service from client's API if you want ;)
from service-mocker.
v1.0.0 is out 👏
from service-mocker.
Related Issues (20)
- Integration with CRA? HOT 16
- Chainable baseURL HOT 8
- javascript errors sometimes get swallowed when inspector is running on reload HOT 7
- ngc+AOT+webpack - compile error HOT 3
- Don't put typings as dependencies HOT 11
- Project Phoenix - roadmap of ver. 2
- Hanging in chrome after reloading
- Problems with basinc routing HOT 7
- Auto reload with webpack HOT 9
- Wildcard URL param doesn't treat well empty param HOT 4
- Add middlewares into the server HOT 19
- createClient(scriptURL).ready does not resolve at root / HOT 8
- Unhandled Promise rejection: Unable to get property 'length' of undefined or null reference ; HOT 4
- Remove hash tags (#) from URL HOT 1
- Support a catch all handler
- Serious bug with route matching with nested routes
- Docs website is broken HOT 2
- Use in browser directly
- Browserify example
- Is this project still active? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from service-mocker.