JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 61930
  • Score
    100M100P100Q168821F
  • License MIT

Wrapper for request module that saves all traffic as a HAR file, useful for auto mocking a client

Package Exports

  • request-capture-har

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (request-capture-har) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

request-capture-har

Wrapper for request module that saves all traffic as a HAR file.

Build Status Dependency Status devDependency Status js-semistandard-style

Usage

// require in request-capture-har in place of request
const request = require('request-capture-har');

// ...
// Use request as you normally would
// ...

// Save HAR file to disk 
request.saveHar(`network-waterfall_${new Date().toISOString()}.har`);

// You can also clear any collected traffic
request.clearHar();

This repo is a fork of larsthorup's node-request-har-capture. Instead of monkey-patching request-promise, we now are based on request including their streaming API. We also added better support for transfer timings.

image Above is a HAR captured by using request-capture-har from within npm to capture an npm install.

Background

This is especially useful for capturing all test traffic from your back-end test suite, for doing auto mocking in your front-end test suite. See this project for an example: https://github.com/larsthorup/http-auto-mock-demo. Blog post about this technique: http://www.zealake.com/2015/01/05/unit-test-your-service-integration-layer/