Socket
Socket
Sign inDemoInstall

jest-playback

Package Overview
Dependencies
57
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    jest-playback

Record and playback http requests from your Jest tests


Version published
Weekly downloads
3.2K
decreased by-9.84%
Maintainers
1
Created
Weekly downloads
 

Changelog

Source

v1.0.0 (2017-07-13)

🚀 New Feature
  • Release first version

Readme

Source

jest-playback

npm build greenkeeper

Record and playback http requests from your Jest tests

Changelog

Install

# using npm
npm install --save jest-playback

# using yarn
yarn add jest-playback

Usage

Modify your Jest config so that looks something like:

(./package.json)

{
  "scripts": {
    "test": "jest"
  },
  "jest": {
    "reporters": [
      "default",
      "jest-playback"
    ]
  }
}

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.

Modes

  • run

    • play records
    • enable net connet
  • play

    • play records
    • disable net connet
  • record

    • enable net connect
    • record all requests
  • real

    • enable net connect

Configs

configs are in the reporter's second field:

{
  "jest": {
    "reporters": [
      "default",
      ["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

Development

# 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

License

MIT © Ika

Keywords

FAQs

Last updated on 13 Jul 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc