DEV.co
Open-Source Testing · Netflix

pollyjs

Polly.JS is a Netflix-backed JavaScript library that records, replays, and stubs HTTP interactions for testing. It works in both Node.js and browsers, automatically capturing real API responses and replaying them in tests for speed and determinism.

Source: GitHub — github.com/Netflix/pollyjs
10.3k
GitHub stars
354
Forks
JavaScript
Primary language
Apache-2.0
License (OSI-approved)

Key facts

Objective fields from the source. Values we can't verify are shown as “Unknown” rather than guessed.

FieldValue
RepositoryNetflix/pollyjs
OwnerNetflix
Primary languageJavaScript
LicenseApache-2.0 — OSI-approved
Stars10.3k
Forks354
Open issues58
Latest releaseUnknown
Last updated2025-05-31
Sourcehttps://github.com/Netflix/pollyjs

What pollyjs is

Framework-agnostic HTTP mocking library that intercepts requests via multiple adapters (XHR, Fetch) and persists interactions as HAR files. Supports request/response interception, pass-through routing, and time manipulation for test scenarios.

Quickstart

Get the pollyjs source

Clone the repository and explore it locally.

terminalbash
git clone https://github.com/Netflix/pollyjs.gitcd pollyjs# follow the project's README for install & configuration

Need it deployed, integrated, or customized instead? DEV.co ships production installs.

Best use cases

Test Suite HTTP Isolation

Record production API responses once, replay deterministically in CI/CD without external dependencies. Eliminates flaky tests caused by network latency or API changes.

End-to-End Test Mocking

Simulate various application states (loading, errors, edge cases) by intercepting and modifying responses without modifying production code.

Cross-Browser Testing

Unified HTTP mocking across Node and browser environments with the same API, enabling consistent test behavior on different platforms.

Implementation considerations

  • Requires explicit adapter registration (XHR, Fetch, etc.) and persister selection before instantiation; declarative setup reduces accidental misconfiguration.
  • HAR file format stores full request/response bodies; large test suites may accumulate significant disk space if recordings are not pruned.
  • Recording mode captures real credentials/tokens in HAR files by default; sanitization strategy must be defined in team workflows to prevent secrets in version control.
  • Mocha and QUnit have first-class helpers; integration with other test frameworks (Jest, Playwright, etc.) requires custom configuration or adapter development.
  • No release versioning noted since project creation; last push was 2025-05-31, suggesting ongoing maintenance but requiring verification of breaking changes before upgrade.

When to avoid it — and what to weigh

  • Real-Time Protocol Requirements — Polly records/replays HTTP only; WebSocket, gRPC, or real-time streaming interactions are not supported.
  • Legacy IE or Unsupported Browsers — Adapter coverage depends on the browser environment; no data provided on minimum version requirements or legacy browser support.
  • GraphQL as Primary API Layer — While Polly can intercept GraphQL over HTTP, the HAR format may not capture GraphQL semantics optimally compared to GraphQL-specific mocking tools.
  • Binary Protocol Mocking — Polly is designed for HTTP request/response pairs; binary or non-HTTP protocols require custom adapters not documented in the README.

License & commercial use

Apache License 2.0: permissive OSI-approved license allowing commercial use, modification, and distribution with trademark and patent protections for Apache Software Foundation.

Apache 2.0 permits commercial use in proprietary test suites and CI/CD pipelines. No proprietary license restrictions noted. However, verify compliance with your legal team for bundled distribution or SaaS offerings, particularly regarding patent clauses and liability disclaimers.

DEV.co evaluation signals

Editorial assessment — not user reviews. Directional, with an explicit confidence level.

SignalAssessment
MaintenanceActive
DocumentationAdequate
License clarityClear
Deployment complexityModerate
DEV.co fitGood
Assessment confidenceHigh
Security considerations

HAR files store plaintext request/response bodies, including headers and POST data; sensitive credentials, tokens, or PII must be explicitly filtered before committing to version control. No documented sanitization hooks or secrets detection in the README. Team must enforce pre-commit filtering policies. Replay-only mode reduces risk compared to live API calls but does not eliminate data exposure if HAR files are leaked.

Alternatives to consider

Pretender

Lightweight XHR/Fetch stubbing library (mentioned as prior art); preferred if persistence and Node adapters are not required.

MSW (Mock Service Worker)

Modern API mocking at the network level with strong TypeScript support and Playwright integration; better for headless browser testing.

Nock

Node.js-specific HTTP mocking library; simpler for backend testing but lacks browser support and recording/replay GUI.

Software development agency

Build on pollyjs with DEV.co software developers

Consider Polly.JS if your team needs deterministic HTTP mocking with recording capabilities across Node and browser environments. Verify security practices for HAR file sanitization and confirm adapter support for your test framework before adoption.

Talk to DEV.co

Related open-source tools

Surfaced by semantic similarity across the DEV.co open-source index.

Related on DEV.co

Explore the category and the services that help you build with it.

pollyjs FAQ

Can Polly record and replay HTTPS and redirect responses?
Yes; the HAR example shows HTTPS URLs and response codes. Timings and cache behaviors are captured in HAR 1.2 format. Refer to documentation for redirect handling specifics.
What happens if a test requests a URL not in the recording?
Default mode records new requests on first encounter and replays them thereafter. Pass-through mode allows unmocked requests to hit the real API. Refer to adapter configuration for fallback behavior options.
Is there a browser GUI for managing recordings?
Not mentioned in the README or data provided. Recordings are HAR files managed via disk or localStorage. Unknown if official tooling exists for inspection/editing.
How do I use Polly with Jest or Playwright?
Jest is not listed as having first-class helpers; custom setup required. Playwright support is not documented. Requires manual adapter and persister configuration or community plugins not listed in README.

Custom software development services

Need help beyond evaluating pollyjs? DEV.co is a software development agency offering software development services and web development for teams of every size. Our software developers and web developers build custom software, web applications, APIs, and open-source testing integrations — and maintain them long-term.

Evaluate Polly.JS for Your Test Suite

Consider Polly.JS if your team needs deterministic HTTP mocking with recording capabilities across Node and browser environments. Verify security practices for HAR file sanitization and confirm adapter support for your test framework before adoption.