1.1.0 • Published 6 years ago

back-to-the-fixture v1.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

Back to the Fixture

Simple recording & replaying of HTTP requests for predictable development & testing.

Example

Given a GraphQL server:

import { recorder } from "back-to-the-fixture";
import graphql from "express-graphql";

export default graphql((req: Request, res: Response) => {
  // šŸ‘‡ Pull ?mode=record or ?mode=replay
  const { mode } = req.query;

  // šŸ‘‡ Create a recorder for this request
  recorder.configure({ mode });

  return {
    graphiql: true,
    pretty: true,
    schema
  };
});

Fixtures are stored based on their URL with the name ${hash}.${user}.json:

.
└── __fixtures__
 Ā Ā  └── api.github.com
 Ā Ā      └── rate_limit
 Ā Ā          └── 4280543676.all.json

This way, similar requests for different users/logins in your testing can be easily found.

Installation

yarn add --dev back-to-the-fixture