Skip to content
This repository has been archived by the owner on Aug 16, 2019. It is now read-only.
/ polly-proxy Public archive

HTTP proxy which uses the Polly.JS library to record and replay test data

Notifications You must be signed in to change notification settings

dustinsoftware/polly-proxy

Repository files navigation

polly proxy

Greenkeeper badge

A proxy server configurable at runtime that can record and replay HTTP web requests. Uses the Polly.JS library by Netflix, and node-http-proxy.

It was designed for use by applications written in any language (such as C#) that make external web requests during integration tests. Ideally you would consume Polly.JS directly in your tests so that the extra layer of indirection is unnecessary.

Usage:

  • Install polly-proxy via npx polly-proxy or npm i -g polly-proxy
  • Start the polly proxy service locally before your tests run.
  • Register a service to be proxied. You will receive a JSON response with the open port you can send requests to. (repeat for all services)
    • POST /addproxy?proxyPath=${encodeURIComponent('http://myservice.example.com')}.
  • Start a test session. Test data will be recorded using the provided test name.
    • POST /replay?testName=your-unique-test-name-here
    • Any API calls that were not present in the recorded data will be externally made and the response persisted.
      • Each time replay is called, the current replay will be stopped and started over from the beginning.
  • Make HTTP requests from your app, but change the base URL to http://localhost:(port). For example, if the port returned /addproxy was 56064, and the URL was http://myservice.example.com/getsomething/foo, have your app make requests to http://localhost:56064/getsomething/foo.
    • Right now the order of the requests does not matter, but you can fork this library and change the polly settings to whatever you want here
  • Stop the test session when your test completes. This will record a HAR file to disk locally, which will be used in future replays.
    • POST /stop?testName=your-unique-test-name-here
  • See this test as an example for how to consume the API
  • Read the Polly.JS documentation for more information on how the record-replay logic works.

Limitations:

  • Does not support parallel tests (yet!)
  • Proxies will be automatically cleaned up after a short time
  • The Polly.JS options are not yet configurable. Fork this library or open an issue with what you'd like to see exposed.

About

HTTP proxy which uses the Polly.JS library to record and replay test data

Resources

Stars

Watchers

Forks

Packages

No packages published