Sometimes you come across situations in which you need to use an api that is either not ready yet or does not behave in an expected way on local.
In that case you can just mock it!
- Install NodeJs v18 or above
- Install dependencies by doing
yarn
- Run the project with
yarn start
Your application will start up on http://localhost:8085
.
If you want to change the port to a different one, you can change it
in the package.json
by adjusting "start": "API_PORT=8085 node src/index.js",
You can add mocks in /assets/mocks.json
.
You can specify a req (Request) that should be mocked and a res (Response) that should be returned.
Currently only these fields are supported:
Request:
- method
- path
- query
Response:
- status
- body
- headers
Your requests will be mocked based on this prioritization:
- A mock with an equal query exists.
- The order of the mocks in
/assets/mocks.json