• Stars
    star
    137
  • Rank 266,121 (Top 6 %)
  • Language
    JavaScript
  • License
    Apache License 2.0
  • Created over 6 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

✨ Scenario-based HTTP 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.

More Repositories

1

jest-image-snapshot

✨ Jest matcher for image comparisons. Most commonly used for visual regression testing.
JavaScript
3,821
star
2

react-albus

✨ React component library for building declarative multi-step flows.
JavaScript
1,094
star
3

earlybird

EarlyBird is a sensitive data detection tool capable of scanning source code repositories for clear text password violations, PII, outdated cryptography methods, key files and more.
Go
697
star
4

xcprojectlint

A security blanket for Xcode project files
Swift
504
star
5

nodes

A GraphQL JVM Client - Java, Kotlin, Scala, etc.
Java
307
star
6

one-app

✨ a fresh, modular take on web application development
JavaScript
292
star
7

baton

HTTP load testing witten in Go
Go
264
star
8

iguazu

✨ Iguazu is a simple Redux-powered Async Query engine
JavaScript
202
star
9

busybee

BusyBee is an alternative API for IdlingResources in Espresso tests
Kotlin
189
star
10

jest-json-schema

✨ JSON schema matcher for Jest
JavaScript
169
star
11

unify-flowret

A lightweight Java based orchestration engine
Java
98
star
12

holocron

✨Set of packages that are used to compose and load React components, enabling the updating and launching of server side rendered user experiences without server restarts
JavaScript
80
star
13

unify-jdocs

A new way of working with JSON documents without using model classes or JSON schemas
Java
72
star
14

hyperledger-fabric-sdk-php

Client SDK for Hyperledger Fabric for use in PHP applications
PHP
47
star
15

react-seo

✨ Simple SEO tag manager for React
JavaScript
45
star
16

fetchye

✨ If you know how to use Fetch, you know how to use Fetchye [fetch-yae]. Simple React Hooks, Centralized Cache, Infinitely Extensible.
JavaScript
41
star
17

eslint-config-amex

✨ This is American Express' eslint config
JavaScript
40
star
18

one-app-cli

✨A set of command line interface (CLI) tools for bundling One App, it's modules, and property files(locale and environment specific files).
JavaScript
36
star
19

k8s-prometheus-proxy

JavaScript
28
star
20

css-to-js

✨ Tool for transforming CSS into JS
JavaScript
28
star
21

grpc-k8s-health-check

A gRPC client-server application illustrating health checks of gRPC servers on Kubernetes
Go
27
star
22

amex-api-java-client-core

Library for authenticating with APIs published to the Amex for Developers portal.
Java
26
star
23

simplemli

Encode and Decode Message Length Indicators for TCP/IP socket based protocols
Go
25
star
24

synapse

Synapse is a set of lightweight foundational framework modules for rapid development, built-in with enterprise-grade maturity and quality.
Java
25
star
25

sfdx-cli-plugin

A plugin for the Salesforce DX CLI based on the Open CLI Framework (OCLIF)
TypeScript
24
star
26

one-service-worker

✨ Minimal, light-weight, Promise based library that unifies the service worker and browser threads under one API
JavaScript
23
star
27

purgecss-loader

✨ A Webpack loader to strip unused selectors from your CSS
JavaScript
22
star
28

redux-lifesaver

✨ redux-lifesaver is a middleware that keeps track of how many times actions of the same type are dispatched within a given period.
JavaScript
22
star
29

iguazu-rest

✨ Iguazu REST is a plugin for the Iguazu ecosystem that allows for pre-built async calls for REST with smart caching.
JavaScript
21
star
30

bucketlist

See what's in your BitBucket Server
Kotlin
18
star
31

react-conditional-flow

React components on top of control flow operations like if, if-else, if-else-if, switch-case, & try-catch
JavaScript
17
star
32

redux-idle-callback

✨ Redux middleware to dispatch actions during a Redux store's idle periods
JavaScript
16
star
33

babel-preset-amex

✨ Standard babel preset for American Express
JavaScript
16
star
34

iguazu-graphql

✨ Iguazu GraphQL is a plugin for the Iguazu ecosystem that allows for GraphQL requests backed by a simple cache.
JavaScript
16
star
35

amex-jest-preset

✨ An opinionated Jest preset
JavaScript
14
star
36

fetch-enhancers

✨ Library of middleware for enhancing Fetch
JavaScript
13
star
37

amex-jest-preset-react

✨ An opinionated Jest preset for React modules
JavaScript
13
star
38

xcode-result-bundle-processor

xcode-result-bundle-processor converts Xcode test result bundles into friendly HTML reports
Ruby
12
star
39

lumberjack

✨ Lumberjack is a minimal, configurable Console with utilities.
JavaScript
12
star
40

vitruvius

✨Vitruvius extends redux's combineReducers to allow developers to include a buildInitialState method on their reducer
JavaScript
11
star
41

jexm

Library to facilitate reading from Excel files
Java
10
star
42

targeted-offers-client

SDK for AMEX targeted offers API
JavaScript
10
star
43

task-status-pr-checker

This is triggered when a pull request is created. If the pull request has pending tasks. The pull request won't be merged and the status is updated on the pull request checks.
JavaScript
10
star
44

codeandsolve

9
star
45

parrot-jest-image-snapshot-example

✨ Example demonstrating usage of parrot for more deterministic jest-image-snapshot tests
JavaScript
9
star
46

amex-api-dotnet-client-core

Library for authenticating with APIs published to the Amex for Developers portal.
C#
9
star
47

express-checkout-tutorials

Code samples for use with Express Checkout API
HTML
8
star
48

one-app-ducks

✨Redux ducks used within the One App ecosystem.
JavaScript
8
star
49

env-config-utils

✨ Utilities for runtime configuration validations
JavaScript
8
star
50

create-shared-react-context

✨A memoized wrapper around React.createContext. Used by One App as a dependency to pass React context between Holocron modules without external usage.
JavaScript
8
star
51

middle-manager

An easy migration path away from the Java WorkManager concurrency API
Java
7
star
52

dux-socket

WebSocket middleware for Redux applications
JavaScript
7
star
53

one-app-dev-cdn

✨ Load remote modules for local development
JavaScript
7
star
54

gabby

Gabby provides a way to interface with several chatbot providers through "adapters". Adapters interface with different services such as api.ai and Watson Conversation.
TypeScript
7
star
55

json-parse-context

✨ Add the context of a json parse error to the error message with syntax highlighting if possible.
JavaScript
6
star
56

jacos

Java/Spring based SDK to enable insert, update and upsert of files and records in the SalesForce in Bulk, Single Record and Multi Record Mode
Java
6
star
57

react-iterative-flow

JavaScript
6
star
58

one-app-dev-proxy

✨ Proxy requests to remote servers locally while also allowing for an express middleware to be provided and applied to all requests
JavaScript
6
star
59

easydist

An end-to-end distributed deep learning tool that mimics the single-machine keras programming model
Python
6
star
60

findxcprojorphan

Finds source files unreferenced in Xcode project
Ruby
5
star
61

SPAN

A stored procedures framework
Java
5
star
62

jakasu

Powerful config driven SDK to easily consume events from one or multiple Kafka topics in both standard and streaming modes
Java
5
star
63

iguazu-rpc

✨ Iguazu RPC is a plugin for the Iguazu ecosystem that allows for configurable async calls and caching strategies.
JavaScript
5
star
64

fabric-integration

Project born out of a need to have a "stable" interface to the Fabric node SDK across various versions.
TypeScript
5
star
65

mlflow-server-proxy

Jupyter server proxy extension for mlflow tracking server
Python
4
star
66

bloom

BLooM is a configuration driven bigdata framework to load massive data into MemSQL
Java
4
star
67

suwannee

RESTful API to enable smart contract interaction from any language or platform
TypeScript
4
star
68

create-using-template

JavaScript
4
star
69

un-locode-java

Java
4
star
70

dydaq

DyDaQ framework connects GraphQL service layer with database efficiently
Java
4
star
71

omnitransform

Declarative and config driven Big Data/ETL framework based on Apache Spark
Java
3
star
72

rate-limiting-scheduled-executor

Java
3
star
73

jakapu

Config driven SDK to publish events into any Kafka topic without writing code
Java
3
star
74

yelp-search

Programmatically search Yelp for businesses using the public version 2.0 of the Yelp Search API
Swift
3
star
75

hide

Config Driven Big Data component which can generate data extracts in various formats from any Hive Tables
Shell
3
star
76

connectchain

Python
2
star
77

chaincode-guide

1
star