

If we configure a stub that expects specific data in the request body and give itĪ higher priority than the existing POST stub that returns 201 then we can Let’s suppose we want to test the case where our app tries to post a new contactīut the API returns a 503 Service Unavailable response instead of the expected 201. With the help of the priority stub parameter. We can configure our mock API to return errors in response to specific requests Sometimes we want to be able to support negative tests, for instance when theĪPI we’re calling returns an error rather than the expected response. You can find out more about Scenarios here. Which you can do by clicking, which resets all scenarios to “Started”. The scenario will now remain in state “2 companies” until it is manually reset, Then when we fetch the companies list a second time we should see two companies The first time we make a request to GET our companies we should see a single item in the collection: So that it appears to have the effect of storing the new company: This stub would also be in the “Companies” scenario but this time with a differentįinally, we’d configure the stub that handles the POST to advance the state of the scenario Make sure you choose the “blank” template on the new API form. Once you’ve signed up or logged back in, create a blank mock API by hitting This is not esssential as it’ll be explained in the places it’s used.įirstly, you’ll need to sign up for a MockLab account if you don’t already have one.
#Create mock data online how to
You’ll also implement common REST patterns and see how to solve common problems. Which is suitable for integration, functional and performance testing. In this tutorial you’ll build a mock REST API from a fictitious contact manager,

Inevitably this means that teams are delayed shipping new features when APIs aren’tįinished, sandbox environments are down or test scenarios can’t be run, so beingĪble to quickly deploy a mock API is essential to keep things moving. Sometimes many REST APIs to the the job done. Mobile and microservice developers to have to integrate with at least a few and REST is the dominant style of API at present and it’s common for web,
