All Projects → americanexpress → Parrot

americanexpress / Parrot

Licence: apache-2.0
✨ Scenario-based HTTP mocking

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Parrot

Msw
Seamless REST/GraphQL API mocking library for browser and Node.js.
Stars: ✭ 7,830 (+7083.49%)
Mutual labels:  devtools, mock, mocking
Wiremockui
Wiremock UI - Tool for creating mock servers, proxies servers and proxies servers with the option to save the data traffic from an existing API or Site.
Stars: ✭ 38 (-65.14%)
Mutual labels:  mock, mocking
Kakapo.js
🐦 Next generation mocking framework in Javascript
Stars: ✭ 535 (+390.83%)
Mutual labels:  mock, mocking
Really Need
Node require wrapper with options for cache busting, pre- and post-processing
Stars: ✭ 108 (-0.92%)
Mutual labels:  mock, mocking
Unit Threaded
Advanced unit test framework for D
Stars: ✭ 100 (-8.26%)
Mutual labels:  mock, mocking
Mimic
Seamless client side mocking
Stars: ✭ 380 (+248.62%)
Mutual labels:  mock, mocking
Pytest Responsemock
Simplified requests calls mocking for pytest
Stars: ✭ 24 (-77.98%)
Mutual labels:  mock, mocking
Gock
HTTP traffic mocking and testing made easy in Go ༼ʘ̚ل͜ʘ̚༽
Stars: ✭ 1,185 (+987.16%)
Mutual labels:  mock, mocking
Moka
A Go mocking framework.
Stars: ✭ 53 (-51.38%)
Mutual labels:  mock, mocking
Generator Http Fake Backend
Yeoman generator for building a fake backend by providing the content of JSON files or JavaScript objects through configurable routes.
Stars: ✭ 49 (-55.05%)
Mutual labels:  mock, mocking
Mockolo
Efficient Mock Generator for Swift
Stars: ✭ 327 (+200%)
Mutual labels:  mock, mocking
Mockery
Mockery is a simple yet flexible PHP mock object framework for use in unit testing with PHPUnit, PHPSpec or any other testing framework. Its core goal is to offer a test double framework with a succinct API capable of clearly defining all possible object operations and interactions using a human readable Domain Specific Language (DSL).
Stars: ✭ 10,048 (+9118.35%)
Mutual labels:  mock, mocking
Firebase Mock
Firebase mock library for writing unit tests
Stars: ✭ 319 (+192.66%)
Mutual labels:  mock, mocking
Ohhttpstubs
Stub your network requests easily! Test your apps with fake network data and custom response time, response code and headers!
Stars: ✭ 4,831 (+4332.11%)
Mutual labels:  mock, mocking
Pook
HTTP traffic mocking and testing made simple in Python
Stars: ✭ 257 (+135.78%)
Mutual labels:  mock, mocking
Hippolyte
HTTP Stubbing in Swift
Stars: ✭ 109 (+0%)
Mutual labels:  mock, mocking
Retromock
Java library for mocking responses in a Retrofit service.
Stars: ✭ 48 (-55.96%)
Mutual labels:  mock, mocking
automock
A library for testing classes with auto mocking capabilities using jest-mock-extended
Stars: ✭ 26 (-76.15%)
Mutual labels:  mock, mocking
Graphql Query Test Mock
Easily mock GraphQL queries in your Relay Modern / Apollo / any-other-GraphQL-client tests.
Stars: ✭ 49 (-55.05%)
Mutual labels:  mock, mocking
Cuckoo
Boilerplate-free mocking framework for Swift!
Stars: ✭ 1,344 (+1133.03%)
Mutual labels:  mock, mocking

Parrot

Parrot is a set of tools that allow you to create HTTP mocks and organize them into scenarios in order to develop your app against different sets of data. We have implemented all of Parrot's functionality in JavaScript, but scenarios are a general specification that can be implemented in any language.

👩‍💻 Hiring 👨‍💻

Want to get paid for your contributions to parrot?

Send your resume to [email protected]

🤹‍ Usage

Let's walk through a common development workflow using Parrot.

Define your scenarios

import { describe, it, get, post, graphql } from 'parrot-friendly';
import casual from 'casual'; // for generating fake data
import schema from './schema'; // our GraphQL schema

const scenarios = describe('Ship Log', () => {
  it('has a ship log', () => {
    // respond with a mock JSON file and add a delay
    get('/ship_log')
      .response(require('./mocks/shipLog.json'))
      .delay(1200);

    // respond with the request body that was sent
    post('/ship_log').response(req => req.body);
  });

  it('has a random ship log', () => {
    // respond with random data generated by casual
    get('/ship_log').response(() => [
      {
        port: casual.city,
        captain: casual.full_name,
      },
    ]);
  });

  it('has a server error', () => {
    // respond with a 500 status
    get('/ship_log').status(500);
  });

  it('has a ship log from GraphQL', () => {
    // respond to GraphQL queries
    graphql('/graphql', schema, () => ({
      ShipLog: () => require('./mocks/shipLog.json'),
    }));
  });
});

export default scenarios;

More information about writing scenarios can be found in the scenarios documentation.

Add them to your server

import express from 'express';
import parrot from 'parrot-middleware';
import scenarios from './scenarios';

const app = express();
app.use(parrot(scenarios));
app.listen(3000);

Develop with Parrot's devtools

parrot-devtools

Example API requests

Fetch current scenario.

$ curl 'http://localhost:3002/parrot/scenario'

Fetch all scenarios.

$ curl 'http://localhost:3002/parrot/scenarios'

Setting parrot to a new scenario.

$ curl -X POST -H "Content-Type: application/json" -d '{ "scenario": "[scenario name here]" }'  'http://localhost:3002/parrot/scenario'

📦 Packages

Parrot is divided into several packages that can be used together depending on your use case.

Name Description
parrot-core Core Parrot functionality that can be extended to new use cases
parrot-devtools Devtools that allow you to switch between Parrot scenarios
parrot-fetch Fetch mocking implementation of Parrot
parrot-friendly Helper library to write your scenarios in BDD style
parrot-graphql Helper library to add GraphQL mocks to your scenarios
parrot-middleware Express middleware implementation of Parrot
parrot-server CLI to get a parrot server up and running

🏆 Contributing

We welcome Your interest in the American Express Open Source Community on Github. Any Contributor to any Open Source Project managed by the American Express Open Source Community must accept and sign an Agreement indicating agreement to the terms below. Except for the rights granted in this Agreement to American Express and to recipients of software distributed by American Express, You reserve all right, title, and interest, if any, in and to Your Contributions. Please fill out the Agreement.

Please see our CONTRIBUTING.md.

🗝️ License

Any contributions made under this project will be governed by the Apache License 2.0.

🗣️ Code of Conduct

This project adheres to the American Express Community Guidelines. By participating, you are expected to honor these guidelines.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].