# netflix/pollyjs

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/netflix-pollyjs).**

10,253 stars · 353 forks · JavaScript · Apache-2.0

## Links

- GitHub: https://github.com/Netflix/pollyjs
- Homepage: https://netflix.github.io/pollyjs
- awesome-repositories: https://awesome-repositories.com/repository/netflix-pollyjs.md

## Topics

`browser` `javascript` `netflix` `nodejs` `record` `replay` `testing`

## Description

Pollyjs is an HTTP mocking and recording library designed to capture and replay network interactions to create deterministic tests. It functions as a request interceptor and stubbing framework that records real API responses into files, ensuring consistent test results across different environments without relying on live network servers.

The tool utilizes pluggable network adapters to support various environments and employs a state-based mode switching system to toggle between recording, replaying, and stubbing behaviors. It uses pattern-based request matching and persistent interaction storage to serve identical responses to incoming requests.

The library covers a broad range of API integration capabilities, including network traffic simulation and the management of request flows. It provides mechanisms for returning custom status codes and mocked data to test edge cases and validate application behavior during automated integration testing.

## Tags

### Programming Languages & Runtimes

- [HTTP Mocking Libraries](https://awesome-repositories.com/f/programming-languages-runtimes/node-js-network-libraries/http-mocking-libraries.md) — A comprehensive library for capturing and replaying HTTP interactions to create deterministic tests.

### Networking & Communication

- [HTTP Response Stubbing](https://awesome-repositories.com/f/networking-communication/http-request-customization/custom-http-response-serving/http-response-stubbing.md) — Returns predefined responses and custom status codes to simulate various server behaviors and edge cases. ([source](https://cdn.jsdelivr.net/gh/netflix/pollyjs@master/README.md))
- [Request Matching](https://awesome-repositories.com/f/networking-communication/communication-protocols-architectures/request-processing-architectures/request-matching.md) — Identifies the correct recorded response by comparing request URIs and headers against predefined rules.

### Testing & Quality Assurance

- [API and Network Testing](https://awesome-repositories.com/f/testing-quality-assurance/api-network-testing.md) — Records and replays network requests to create deterministic tests that do not rely on a live backend.
- [HTTP Interaction Recording](https://awesome-repositories.com/f/testing-quality-assurance/api-network-testing/network-testing/http-interaction-recording.md) — Provides the ability to capture outgoing network requests and responses to save them for later reuse in tests. ([source](https://cdn.jsdelivr.net/gh/netflix/pollyjs@master/README.md))
- [Integration Test Suites](https://awesome-repositories.com/f/testing-quality-assurance/automated-test-suites/integration-test-suites.md) — Captures real network traffic to build reliable integration test suites that run without external dependencies.
- [HTTP Stubbing Frameworks](https://awesome-repositories.com/f/testing-quality-assurance/http-request-clients/api-request-clients/request-testing/stub-registries/http-stubbing-frameworks.md) — Provides a system for returning custom status codes and mocked data for specific network requests to test edge cases.
- [HTTP Mocking](https://awesome-repositories.com/f/testing-quality-assurance/node-js-test-automation/http-mocking.md) — Simulates specific server responses and edge cases by stubbing network calls.
- [Deterministic Testing Utilities](https://awesome-repositories.com/f/testing-quality-assurance/deterministic-testing-utilities.md) — Provides a utility for recording real API responses to ensure consistent test results across different environments.
- [HTTP Traffic Simulation](https://awesome-repositories.com/f/testing-quality-assurance/http-traffic-simulation.md) — Controls the flow of HTTP requests to regulate traffic and test application behavior under various connectivity scenarios.

### Web Development

- [HTTP Request Interceptors](https://awesome-repositories.com/f/web-development/http-request-interceptors.md) — Provides a middleware layer that captures outgoing network calls and returns predefined responses.
- [Request Interception Middleware](https://awesome-repositories.com/f/web-development/request-interception-middleware.md) — Intercepts outgoing network calls to determine if they should be routed to a live server or a mock response.

### Data & Databases

- [Response Recordings](https://awesome-repositories.com/f/data-databases/api-response-caching/response-recordings.md) — Matches incoming requests against stored recordings to serve identical responses and ensure consistent outcomes.
- [Interaction Recording Storage](https://awesome-repositories.com/f/data-databases/data-engineering-infrastructure/data-persistence-storage/data-storage/interaction-state-storage/interaction-recording-storage.md) — Saves captured request and response pairs to a file system or database for reuse across test executions.

### Software Engineering & Architecture

- [HTTP Client Adapters](https://awesome-repositories.com/f/software-engineering-architecture/integration-adapters/http-client-adapters.md) — Abstracts the underlying HTTP client to support different environments like browsers or Node.js.
- [Request Interception Control](https://awesome-repositories.com/f/software-engineering-architecture/request-interception-control.md) — Controls whether network calls are intercepted or passed to a server to regulate traffic during test execution. ([source](https://cdn.jsdelivr.net/gh/netflix/pollyjs@master/README.md))
