Giter Site home page Giter Site logo

twofriedeggs / mockery Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 1.0 227 KB

An Open Source service to mock your upstreams. Used during performance testing, development and QA to dynamically simulate a response and test the app behaviour.

License: MIT License

JavaScript 5.62% TypeScript 87.93% Dockerfile 6.45%
performance development qa mock upstream nextjs mockery dynamic

mockery's Introduction

Mockery

Docs

  • It can send a static template (JSON, HTML)
  • It can update the template with a new file type.
  • It can create presets
  • It can send presets
  • It can automate which preset to send based on time, response path, after a certain request count, a hybrid combination of it
  • It can throttle the response time
  • It can dynamically filter the response and manipulate it
  • It can call a response from an predefined upstream by
  • It can send custom status, headers
  • It supports the following protocols:
  • It supports CORS

Container

docker build -t mockery .

docker run --detach --name mockery --publish 80:8080 mockery

Configuration

{
	type: 'proxy',
	protocol: 'https',
	host: 'api.nasa.gov',
	delay: null
};
{
	type: 'fixture',
	status: 200,
	headers: {
		'x-custom-header': 'Custom Value',
		'Content-Type': 'text/javascript'
	},
	body: '{"key": "value"}',
	delay: null
};

Headers

It's an object containing key/value pairs representing the header to return

headers: {
	'Content-Type': 'text/javascript',
	'X-Custom-Header': 'some custom value',
}

Delay

Adds an artificial delay to the response. The delay can be:

A random delay between a set interval

delay: {
	type: 'random-delay',
	min: 120,
	max: 300
}

A set number

delay: {
	type: 'set-delay',
	value: '500'
}

A timeout (no response is returned)

delay: {
	type: 'timeout'
}

Examples

import type { NextApiRequest, NextApiResponse } from 'next'

export default async (request: NextApiRequest, response: NextApiResponse) => {
  const { id } = request.query;
  let user = '';
  try {
    user = (await import(`fixtures/users/${id}`)).default;
    response.status(200).json(user);
  } catch (error) {
    console.log(error.message);
    response.status(404).json({ error: error.message });
  }
}

mockery's People

Contributors

simonespa avatar

Watchers

 avatar

Forkers

simonespa

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.