What is API Mocking?

A mock API imitates a real API by providing realistic responses for API requests. These APIs can be on your local computer or hosted on the public internet. It basically fakes the behaviour of real API.

Why API Mocking?

  1. The real APIs are not available yet but the API contracts are final. Frontend developers can start working in parallel with backend developers once API mocks are in place.
  2. It’s easy to change the responses of a mock API than to change the exact logic in a real API.
  3. API automation team can write automation test cases with basic assertions which can be run later when the real APIs are available.
  4. If Real APIs are slow, mock APIs can be used for development purposes.
  5. Mock APIs comes in handy when you are working offline and mock APIs are hosted on your local computer.

How to mock API using JSON-Server

JSON Serveris a Node Module that we can use to mock a REST API service. It is one of the easiest and fastest ways of adding a mock REST API with a minimum configuration.

#api #software-development #testing #json

How to Mock API using JSON-Server
2.05 GEEK