Socket
Socket
Sign inDemoInstall

jest-playback

Package Overview
Dependencies
332
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

3.0.0 (2020-07-29)

Features

  • upgrade Nock to v13 (#411) (9ec364e)

BREAKING CHANGES

  • require Node 10+

<a name="2.0.2"></a>

Readme

Source

jest-playback

npm build

Record and playback http requests from your Jest tests

Changelog

Install

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

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

Usage

// records are stored in `${__dirname}/__playbacks__`.
require("jest-playback").setup(__dirname);

const request = require("request");

test("example", done => {
  request('http://www.example.com/', (_err, _res, body) => {
    expect(body).toMatchSnapshot();
    done();
  });
});

You can control which mode to use by specifying the second argument of setup:

require("jest-playback").setup(__dirname, "record");

or via the JEST_PLAYBACK_MODE environment variable:

JEST_PLAYBACK_MODE=record npx jest

Modes

  • run (default)

    • play records
    • enable net connet
  • play

    • play records
    • disable net connet
  • record

    • enable net connect
    • record all requests
  • real

    • enable net connect

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 29 Jul 2020

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