Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

http2spy

bcoe506Apache-2.02.0.2TypeScript support: included

test helpers for working with Node.js' http2 module

http2, spy, testing

readme

http2spy

Build Status nycrc config on GitHub Conventional Commits

Spy on nodejs' built-in http2 module and assert against requests that have been performed:

const assert = require("assert");
const http2spy = require("http2spy");
const myClient = http2spy.require(require.resolve("./lib/my-client"));

// do something with your http2 API client, e.g.,
// client.request({ ":method": "GET", ":path": "/" });

// now examine the requests:
assert.strictEqual(http2spy.requests[0][":method"], 'GET');

Passing Additional Stubs

http2spy is just a thin wrapper on top of proxyquire, if you would like to pass additional libraries to stub, simply provide them as a second parameter:

const myClient = http2spy.require(require.resolve("./lib/my-client"), {
  'second-library': {
    foo: () => {}
  }
});

License

Apache Version 2.0

changelog

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

2.0.2 (2020-07-13)

Bug Fixes

2.0.1 (2020-07-08)

Bug Fixes

  • include files and dependencies in package (#19) (5c4f85d)

2.0.0 (2020-06-11)

⚠ BREAKING CHANGES

  • drop support for node.js 8.x (#11)

Features

Build System

1.1.0 (2019-08-16)

Features

  • allow additional stubs to be passed (#5) (81e3a76)
  • initial implementation (d5a7c18)