Speed up a slow test suite by recording HTTP responses once and replaying them without hitting real servers on future runs
Simulate API error states by intercepting requests and returning custom status codes without configuring a real server
Write reliable frontend or Node.js tests that pass even when external APIs are down or return different data
Capture and replay both fetch and XHR browser requests in automated tests without writing manual mocks
Storage persisters and request adapters are separate npm packages, you must install the right combination for your test environment and storage backend.
Polly.JS is a JavaScript testing tool built by Netflix that helps developers write faster and more reliable automated tests. The core problem it solves is that tests which make real network requests to servers are slow, unpredictable, and can fail for reasons unrelated to the code being tested. Polly.JS addresses this by recording those HTTP requests and their responses the first time a test runs, then replaying the saved recordings on every subsequent run. The workflow goes like this: you run your tests once while connected to real servers, and Polly.JS captures each request and response and saves them to disk or local storage. On future runs, the tests use those saved recordings instead of hitting the network. This makes the test suite run faster and produce consistent results regardless of whether the server is available or what data it currently holds. Beyond recording and replaying, the library lets you intercept individual requests and return whatever response you define, which is useful for simulating error states or loading conditions without needing to configure a real server to behave that way. You can also mark specific requests as pass-through, meaning they still hit the real network even when recording mode is off. Polly.JS works in both Node.js and the browser, which is less common among tools of this kind. It connects to the browser fetch and XHR request mechanisms, so it captures the full range of requests your app makes. Adapters for different request libraries and persisters for different storage backends are installed separately as packages, letting you use only what your project needs. The library works with any test framework and includes built-in helpers for Mocha and QUnit. The project is open source under the Apache 2.0 license and was created at Netflix. The README notes the project is in maintenance mode, with development focused on bug fixes rather than new features.
← netflix on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.