talira

Puffing Billy

A rewriting web proxy for testing interactions between your browser and external sites

open sourceMITself-hostablefree

Puffing Billy is like WebMock or VCR, but for the browser: it runs an EventMachine-based proxy that the test browser sends its requests through, so feature specs can stub what external sites return, including HTTPS, redirects, error codes and dynamic responses from a Proc. It can also pass requests through and change them, and cache and replay real responses to disk. It has setups for Capybara (Selenium, Cuprite and other drivers), Watir, RSpec, Minitest and Cucumber.

Problems it solves

  • my Capybara feature specs break when a third-party API the page calls from JavaScript is down
  • stub the HTTP requests the browser makes during feature tests, not only the Ruby server's
  • test how my page behaves when an external widget's API starts returning 500s
  • record the browser's requests to outside sites once and replay them in later test runs
  • fake what Google, Twitter or another embedded script returns to the browser in tests
  • block every external request the test browser makes except the hosts I allow
  • stub HTTPS requests made by headless Chrome in an integration test
  • return JSON or JSONP from a fake endpoint in a JavaScript-heavy browser test
  • make browser integration tests repeatable when the page depends on outside services
  • intercept and change a real upstream response before the test browser sees it

Features

  • stub responses by URL and method: text, JSON, JSONP, redirects and status codes
  • HTTPS stubbing
  • dynamic responses from a Proc
  • pass-through requests that can change the request and the upstream response
  • response cache with persistence, record and replay
  • host whitelists and an option to block non-whitelisted requests
  • Capybara drivers for Selenium (Firefox and Chrome, headless), Cuprite, Apparition and others
  • Watir, RSpec, Minitest and Cucumber setups

Limitations

  • Doesn't proxy WebSockets: ActionCable and other WebSocket connections have to bypass it1

Capabilities

Has an APIplan not known

Alternatives

The same job

These do what Puffing Billy does.

  1. WebMock Library for stubbing and setting expectations on HTTP requests in Ruby.
  2. VCR Record your test suite's HTTP interactions and replay them during future test runs for fast, deterministic, accurate tests.

Compare Puffing Billy with the top 3