Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jest-playback

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jest-playback

Record and playback HTTP requests from your Jest tests

  • 4.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.3K
decreased by-65.48%
Maintainers
1
Weekly downloads
 
Created
Source

jest-playback

npm build

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 {
  /** @default Mode.Auto */
  mode?: Mode
  getRequestCacheKey?: (request: Request) => string | Promise<string>
}

export enum Mode {
  /**
   * - `Mode.Update` if Jest `--update-snapshot` flag specified
   * - `Mode.Play` if Jest `--ci` flag specified
   * - `Mode.Record` otherwise
   */
  Auto = 'auto',
  /**
   * - all requests are recorded
   */
  Update = 'update',
  /**
   * - play records
   * - new requests are blocked
   */
  Play = 'play',
  /**
   * - play records
   * - new requests are recorded
   */
  Record = 'record',
}

Development

# lint
pnpm run lint

# build
pnpm run build

# test with jest
pnpm run test:jest

# test with vitest
pnpm run test:vitest

License

MIT © Ika

Keywords

FAQs

Package last updated on 25 Jul 2023

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc