Code Monkey home page Code Monkey logo

mock-where's Introduction

mock-where Build Status

RESTful-API-driven mock service, with rule engine and web-hook (AKA. callback)

Contents

Target Usage

  • Mock expensive cloud services, such as 3rd-party login and payment that requires fee and complex round-trip: you call them and then they will call back you later; or even worse - they're one-off
  • Mock dependent services for test automation which requires programmatic control
  • Share single mock server inside/across team, by specifying rules to separate mocked responses
  • Locate performance bottleneck by removing external dependencies

Features

  • RESTful API. Create/update/delete/query mock rules with http test client, for ex. postman, curl, soapui, jmeter, and so on
  • Rule Engine. dynamically return different response determined by: headers, path, query, body/parameter and so on
  • Web-hook. Mock callback / notification, such as payment fullfillment
  • Built-in HTTP(s) proxy. Backed by http-proxy; turn on/off for specific rule
  • Recording Request & Response. by in-memory sqlite3 database
  • [Simple Web UI] (https://github.com/qiangyt/mock-where-webui)

Installation

Configuration

{ port: 8000, // optional. if has default port, then take it, otherwise, throws error domain: "github.com", // optional. if has default domain, then take it, otherwise, throws error name: "My rule name", // optional. assigned by default path: "/test", // optional. assigned to default path, if not specified method: "POST", // optional. assigned to default method, if not specified q: "ip='localhost'", // optional. assigned to default query, if not specified latency: 200, // optoinal. assigned to default latency, if not specified latencyFix: 16, // optional. assigned to default latencyFix, if not specified hook: { before: [ {
enabled: false, // optional. true by default method: 'POST', // optional path: 'http://example.com/notify', pathTemplate: {}, // exclusive with path header: {},// optional query: {}, // or string, optional queryTemplate: {}, // exclusive with query type: 'application/json',// optional body: { object: {}, // or string, or stream, or file, optional text: '...', // exclusive with object/template template: {}// exclusive with object/text } accept: 'application/xml' // optional } ], after: [ // same as before ]
}, response: // optional. merged with default response { status: 403, type: "application/json", body: { template: // exclusive with body.object { type: "mustache", // optional. if not specified, assigned to "ejs" // if template is text, otherwise to default response.templateType text: "hi", // optional. if not specified, assigned to "template text not specified" }, object: { // exclusive with "bodyTemplate". // could be any JSON-stringify-able object, string, or primitive value, // "no response body specified", if not specified } } }, proxy: { enabled: true, // optional. false by default path: 'http://example.com/target' } }

API

Working ......

Contributing to Mock-where

Contributions are always welcome, especifiallno matter how large or small. Before contributing, please read the code of conduct.

See Contributing.

In Progress

  • As micro-services (Eureka,...)
  • Recording proxied request/response
  • Web UI to manage rules
  • Use mock.js
  • Dockerization
  • Rule repository for various of cloud services

Any Question or Issue

https://github.com/qiangyt/mock-where/issues/new

Build Status

License

MIT © Qiang Yiting

mock-where's People

Contributors

qiangyt avatar suntoe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

weiloongmao

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.