Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
P

pollyjs

> 测试质量
Open source

Record, Replay, and Stub HTTP Interactions.

10.3K stars0 likes4 views
WebsiteGitHub

About

Record, Replay, and Stub HTTP Interactions.

Record, Replay, and Stub HTTP Interactions

Polly.JS is a standalone, framework-agnostic JavaScript library that enables recording, replaying, and stubbing of HTTP interactions. By tapping into multiple request APIs across both Node & the browser, Polly.JS is able to mock requests and responses with little to no configuration while giving you the ability to take full control of each request with a simple, powerful, and intuitive API.

Interested in contributing or just seeing Polly in action? Head over to CONTRIBUTING.md to learn how to spin up the project!

Why Polly?

Keeping fixtures and factories in parity with your APIs can be a time consuming process. Polly alleviates this process by recording and maintaining actual server responses while also staying flexible.

  • Record your test suite's HTTP interactions and replay them during future test runs for fast, deterministic, accurate tests.
  • Use Polly's client-side server to modify or intercept requests and responses to simulate different application states (e.g. loading, error, etc.).

Features

  • Node & Browser Support
  • ⚡️️ Simple, Powerful, & Intuitive API
  • First Class Mocha & QUnit Test Helpers
  • Intercept, Pass-Through, and Attach Events
  • Record to Disk or Local Storage
  • ⏱ Slow Down or Speed Up Time

Getting Started

Check out the Quick Start documentation to get started.

Usage

Let's take a look at what an example test case would look like using Polly.

…

The above test case would generate the following HAR file which Polly will use to replay the sign-in response when the test is rerun:

…

Prior Art

The "Client Server" API of Polly is heavily influenced by the very popular mock server library pretender. Pretender supports XHR and Fetch stubbing and is a great lightweight alternative to Polly if your project does not require persisting capabilities or Node adapters.

Thank you to all contributors especially the maintainers: trek, stefanpenner, and xg-wang.

Contributors

License

Copyright (c) 2018 Netflix, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Issues· 61 open

View all issuesOpen on GitHub
  • #507

    Path Traversal Leading to Arbitrary File Write

    Updated Sep 16, 2026
  • #504

    Cannot use with typescript: Adapter is not assignable to parameter of type Newable<any>

    Updated Dec 12, 2025
  • #487

    Can polly record and replay websockets requests?

    Updated Oct 10, 2025
  • #505

    Issue attaching to puppeteer. Emitter undefined.

    Updated Mar 3, 2025
  • #503

    PollyError: [Polly] Request failed due to an unknown error. TIMEOUT

    Updated Jan 27, 2025
  • #193

    Need to regenerate records if `matchRequestsBy` changes

    question 🤔:package: coreUpdated Jan 11, 2025
  • #501

    NodeHttpAdapter's use of the non-standard options.href causes different behavior when Polly is enabled

    Updated Sep 11, 2024
  • #499

    [feature] - Vitest support

    Updated Jul 31, 2024
  • #498

    [Bug] Polly replays weird array type from persisted file (replayedData instanceof Array returns false)

    Updated Jun 27, 2024
  • #497

    [Question] What is the purpose of the number on the end of the directory names?

    Updated Jun 26, 2024

> Tags

JavaScriptbrowserjavascriptnetflixnodejs

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 29, 2026
Category测试质量
PricingOpen source

> Related tools

J
Jest
JavaScript 测试框架
P
Playwright
现代端到端测试框架
E
eslint-plugin-test-selectors
Enforces that data-test-id attributes are added to interactive DOM elements (JSX) to help with UI testing. JSX only.