1.1.0 ā€¢ Published 5 years ago

back-to-the-fixture v1.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
5 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