Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bcoe/http2spy
test helpers for working with Node.js' http2 module
https://github.com/bcoe/http2spy
Last synced: 16 days 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 (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-10-14T22:24:24.000Z (28 days ago)
- Last Synced: 2024-10-20T13:54:22.902Z (23 days ago)
- Language: TypeScript
- Size: 40 KB
- Stars: 19
- Watchers: 3
- Forks: 0
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# http2spy
[![Build Status](https://travis-ci.org/bcoe/http2spy.svg?branch=master)](https://travis-ci.org/bcoe/http2spy)
![nycrc config on GitHub](https://img.shields.io/nycrc/bcoe/http2spy)
[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](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