Home

Awesome

Stubmatic

Mock HTTP calls without coding. Designed specially for testing and testers.

NPM quality Travis ci Build Status Gitter Known Vulnerabilities Coverage Status

<a href="https://opencollective.com/stubmatic/donate" target="_blank"> <img src="https://opencollective.com/stubmatic/donate/button@2x.png?color=blue" width=200 /> </a> <a href="https://paypal.me/naturalintelligence"> <img src="static/img/support_paypal.svg" alt="Stubmatic donate button" width="200"/></a> <img align="right" src="https://naturalintelligence.github.io/Stubmatic/img/stubmatic_logo.png?raw=true" width="180px" alt="Stubmatic logo"/>
  1. Installation : $npm install stubmatic -g
  2. Set up repo : $stubmatic init [repo-name]
  3. Start server : $stubmatic [-d <repo-name>]
  4. Help : $stubmatic --help

Important links : Video Tutorial, Wiki, NPM, Demo application, issues, changelogs <img width="180px" src="https://naturalintelligence.github.io/Stubmatic/img/showcase_btn.png" alt="Stubmatic donate button"/>

Users

<a href="https://o2.co.uk/" title="Telefonica O2 UK" > <img src="https://avatars0.githubusercontent.com/u/2110471" width="80px" ></a>

Main features

Configuration

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.

How to start

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.

Sample SOAP request mapping

-  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"]

Sample REST request mapping

-  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"]

Our other projects and research you must try

Supporters

Contributors

This project exists thanks to all the people who contribute. [Contribute].

<a href="graphs/contributors"><img src="https://opencollective.com/stubmatic/contributors.svg?width=890&button=false" /></a>

Backers

Thank you to all our backers! 🙏 [Become a backer]

<a href="https://opencollective.com/stubmatic#backers" target="_blank"><img src="https://opencollective.com/stubmatic/backers.svg?width=890"></a>

Sponsors

<small>[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.</small>

<a href="https://opencollective.com/stubmatic/sponsor/0/website" target="_blank"><img src="https://opencollective.com/stubmatic/sponsor/0/avatar.svg"></a> <a href="https://opencollective.com/stubmatic/sponsor/1/website" target="_blank"><img src="https://opencollective.com/stubmatic/sponsor/1/avatar.svg"></a> <a href="https://opencollective.com/stubmatic/sponsor/2/website" target="_blank"><img src="https://opencollective.com/stubmatic/sponsor/2/avatar.svg"></a> <a href="https://opencollective.com/stubmatic/sponsor/3/website" target="_blank"><img src="https://opencollective.com/stubmatic/sponsor/3/avatar.svg"></a>

Helpful articles and tutorials