Mock HTTP calls without coding. Designed specially for testing and testers.
Mock HTTP calls without coding. Designed specially for testing and testers.
$npm install stubmatic -g
$stubmatic init [repo-name]
$stubmatic [-d <repo-name>]
$stubmatic --help
Important links : Video Tutorial, Wiki, NPM, Demo application, issues, changelogs
To install stubmatic, you need to install nodejs and npm first. It is recommanded to be on latest version of both. npm is bundeled with nodejs. Now follow above commands to install stubmatic and to set up a repo.
Stubmatic works on request response mappings specified in a yaml file. Response contents can be read from body or file attribute of a maping.
- request:
url: /stubs/(admin|staff|customer|security)/([0-9]+)/2
response:
body: >
multiple line response
another line
When a request reaches to stubmatic server, it matches the request against all mappings. Whichever mapping matches first(top to bottom), will be used to serve the response. A complete response can be built with multiple files. It can also have some placeholder to show dynamic data, like date, or some random number or some part from request itself. Stubmatic first process and build complete response then respond back to any HTTP(s) request.
Using regular expression, single mapping can be used to match multiple requests and serve response from different files.
- request:
method: POST
url: /soap-simulator/services/ServiceName
post: actionName[\s\S]*mobile.([0-9]+)
response:
headers:
content-type: text/xml
strategy: "first-found"
files: ["stubs/<% post.1 %>/response.xml","stubs/ServiceName/actionName/default.xml"]
- request:
method: GET
url: /rest-simulator/services/ServiceName/actionName/([0-9]+)
response:
headers:
content-type: text/xml
strategy: "first-found"
files: ["stubs/<% url.1 %>/response.xml","stubs/ServiceName/actionName/default.xml"]
This project exists thanks to all the people who contribute. [Contribute].
Thank you to all our backers! 🙏 [Become a backer]
[Become a sponsor] Support this project by becoming a sponsor. Your logo will show up here with a link to your website. Please also share your detail so we can thankyou on SocialMedia.