https://github.com/bcoe/http2spy
test helpers for working with Node.js' http2 module
https://github.com/bcoe/http2spy
Last synced: 4 months ago
JSON representation
test helpers for working with Node.js' http2 module
- Host: GitHub
- URL: https://github.com/bcoe/http2spy
- Owner: bcoe
- License: apache-2.0
- Created: 2019-08-08T02:01:56.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2025-03-11T22:57:23.000Z (4 months ago)
- Last Synced: 2025-03-11T23:32:06.395Z (4 months ago)
- Language: TypeScript
- Size: 40 KB
- Stars: 19
- Watchers: 2
- Forks: 0
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# http2spy
[](https://travis-ci.org/bcoe/http2spy)

[](https://conventionalcommits.org)Spy on nodejs' built-in [http2 module](https://nodejs.org/api/http2.html) and
assert against requests that have been performed:```js
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](https://www.npmjs.com/package/proxyquire), if you would like to
pass additional libraries to stub, simply provide them as a second parameter:```js
const myClient = http2spy.require(require.resolve("./lib/my-client"), {
'second-library': {
foo: () => {}
}
});
```## License
Apache Version 2.0