- We still use it, but not all the dev time.
- Every time we want to code, test we need to open simulator, so it will be hard for us if we want to use any automation tests later on.
if (env === "DEV") {}
is everywhere, we need to do it just in one place.
- Dev cans change the response whenever they want, we can do even better than that for example we can set the the loading time or set the request to false.
-
We gonna implement something likes this
javascript
const mock = (req) => { req.prototype.send = (successBlock, failureBlock) => { successBlock(window.btoa(writeBinaryString(loginForm))); }return req; }
- We also need to predefine the responses if we gonna call with correct url/parameters (the idea like **[Nock](https://github.com/pgte/nock)**).
- Then wherever can wrap the global `Request` with `mock(Request)`.
PLEASE PLEASE PLEASE PLEASE do not put
if (env === "DEV") {}
everywhere. Abstract the data so far so that it doesn't matter where the data is coming from. You shouldn't be checking for the env type in more than two or three places in the whole project.