jest-playback
Record and playback HTTP requests from your Jest tests
Changelog
Install
npm install jest-playback
Usage
import * as jestPlayback from 'jest-playback'
await jestPlayback.setup()
test('example', async () => {
const response = await fetch('http://www.example.com/')
expect(response.status).toBe(200)
})
The records are stored as snapshots.
API
export default setup
export declare function setup(options?: Options): Promise<void>
export interface Options {
mode?: Mode
getRequestCacheKey?: (request: Request) => string | Promise<string>
}
export enum Mode {
Auto = 'auto',
Update = 'update',
Play = 'play',
Record = 'record',
}
Development
pnpm run lint
pnpm run build
pnpm run test:jest
pnpm run test:vitest
License
MIT © Ika