1.1.0 ā¢ Published 5 years ago
back-to-the-fixture v1.1.0
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
};
});
- Record network calls āĀ http://localhost:3000/?mode=record
- Replay network calls - http://localhost:3000/?mode=replay
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