Record and playback http requests from your Jest tests
TypeScript JavaScript
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.


npm build

Record and playback http requests from your Jest tests



# using npm
npm install --save-dev jest jest-playback

# using yarn
yarn add --dev jest jest-playback

NOTE: This project uses the reporters field, which is available since Jest v20.


Modify your Jest config so that looks something like:


  "scripts": {
    "test": "jest"
  "jest": {
    "reporters": [

If you just want to record requests:

JEST_PLAYBACK_MODE=record npm run test

If you just want to playback records:

JEST_PLAYBACK_MODE=play npm run test

NOTE The default mode is run, which will playback records and still allow unmocked requests.


  • run

    • play records
    • enable net connet
  • play

    • play records
    • disable net connet
  • record

    • enable net connect
    • record all requests
  • real

    • enable net connect


configs are in the reporter's second field:

  "jest": {
    "reporters": [
      ["jest-playback", {"option": "value"}]
  • debug

    • type: boolean
    • default: false
    • display debug message
  • playbacks

    • type: string
    • default: <rootDir>/playbacks
    • specify directory to store records
  • mode

    • type: string
    • default: run
    • specify which mode to use
  • mode_env

    • type: string
    • default: JEST_PLAYBACK_MODE
    • specify what environment variable to be used as mode, has higher priority than mode


# lint
yarn run lint

# build
yarn run build

# test
yarn run test


  • nock: HTTP mocking and expectations library
  • ava-playback: Record and playback http requests from your ava tests


MIT © Ika