JavaScript HTML
Switch branches/tags
@pollyjs/utils@1.0.2 @pollyjs/utils@1.0.1 @pollyjs/utils@1.0.0 @pollyjs/utils@0.1.1 @pollyjs/utils@0.1.0 @pollyjs/persister@1.0.3 @pollyjs/persister@1.0.2 @pollyjs/persister@1.0.1 @pollyjs/persister@1.0.0 @pollyjs/persister@0.2.1 @pollyjs/persister@0.2.0 @pollyjs/persister@0.1.0 @pollyjs/persister-rest@1.0.4 @pollyjs/persister-rest@1.0.3 @pollyjs/persister-rest@1.0.2 @pollyjs/persister-rest@1.0.1 @pollyjs/persister-rest@1.0.0 @pollyjs/persister-local-storage@1.0.4 @pollyjs/persister-local-storage@1.0.3 @pollyjs/persister-local-storage@1.0.2 @pollyjs/persister-local-storage@1.0.1 @pollyjs/persister-local-storage@1.0.0 @pollyjs/persister-fs@1.0.4 @pollyjs/persister-fs@1.0.3 @pollyjs/persister-fs@1.0.2 @pollyjs/persister-fs@1.0.1 @pollyjs/persister-fs@1.0.0 @pollyjs/node-server@1.0.2 @pollyjs/node-server@1.0.1 @pollyjs/node-server@1.0.0 @pollyjs/node-server@0.4.0 @pollyjs/node-server@0.3.0 @pollyjs/node-server@0.2.0 @pollyjs/node-server@0.1.0 @pollyjs/node-server@0.0.2 @pollyjs/node-server@0.0.1 @pollyjs/ember@1.0.4 @pollyjs/ember@1.0.3 @pollyjs/ember@1.0.2 @pollyjs/ember@1.0.1 @pollyjs/ember@1.0.0 @pollyjs/ember@0.4.2 @pollyjs/ember@0.4.1 @pollyjs/ember@0.4.0 @pollyjs/ember@0.3.1 @pollyjs/ember@0.3.0 @pollyjs/ember@0.2.1 @pollyjs/ember@0.2.0 @pollyjs/ember@0.1.0 @pollyjs/ember@0.0.2 @pollyjs/ember@0.0.1 @pollyjs/core@1.1.3 @pollyjs/core@1.1.2 @pollyjs/core@1.1.1 @pollyjs/core@1.1.0 @pollyjs/core@1.0.0 @pollyjs/core@0.5.0 @pollyjs/core@0.4.0 @pollyjs/core@0.3.0 @pollyjs/core@0.2.0 @pollyjs/core@0.1.0 @pollyjs/core@0.0.2 @pollyjs/core@0.0.1 @pollyjs/cli@1.0.2 @pollyjs/cli@1.0.1 @pollyjs/cli@1.0.0 @pollyjs/cli@0.2.1 @pollyjs/cli@0.2.0 @pollyjs/cli@0.1.1 @pollyjs/cli@0.1.0 @pollyjs/cli@0.0.2 @pollyjs/cli@0.0.1 @pollyjs/adapter@1.1.2 @pollyjs/adapter@1.1.1 @pollyjs/adapter@1.1.0 @pollyjs/adapter@1.0.0 @pollyjs/adapter@0.3.1 @pollyjs/adapter@0.3.0 @pollyjs/adapter@0.2.0 @pollyjs/adapter@0.1.0 @pollyjs/adapter@0.0.2 @pollyjs/adapter@0.0.1 @pollyjs/adapter-xhr@1.0.4 @pollyjs/adapter-xhr@1.0.3 @pollyjs/adapter-xhr@1.0.2 @pollyjs/adapter-xhr@1.0.1 @pollyjs/adapter-xhr@1.0.0 @pollyjs/adapter-puppeteer@1.1.3 @pollyjs/adapter-puppeteer@1.1.2 @pollyjs/adapter-puppeteer@1.1.1 @pollyjs/adapter-puppeteer@1.1.0 @pollyjs/adapter-puppeteer@1.0.0 @pollyjs/adapter-fetch@1.0.4 @pollyjs/adapter-fetch@1.0.3 @pollyjs/adapter-fetch@1.0.2 @pollyjs/adapter-fetch@1.0.1 @pollyjs/adapter-fetch@1.0.0
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.


Record, Replay, and Stub HTTP Interactions

Build Status license

Polly.JS is a standalone, framework-agnostic JavaScript library that enables recording, replaying, and stubbing HTTP interactions.

Polly taps into native browser APIs 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 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 by recording and maintaining actual server responses without foregoing flexibility.

  • 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.).


  • 🚀 Fetch & XHR 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.


Lets take a look at what an example test case would look like using Polly.

import { Polly } from '@pollyjs/core';
import XHRAdapter from '@pollyjs/adapter-xhr';
import FetchAdapter from '@pollyjs/adapter-fetch';
import RESTPersister from '@pollyjs/persister-rest';

  Register the adapters and persisters we want to use. This way all future
  polly instances can access them by name.

describe('Netflix Homepage', function() {
  it('should be able to sign in', async function() {
      Create a new polly instance.

      Connect Polly to both fetch and XHR browser APIs. By default, it will
      record any requests that it hasn't yet seen while replaying ones it
      has already recorded.
    const polly = new Polly('Sign In', {
      adapters: ['xhr', 'fetch'],
      persister: 'rest'
    const { server } = polly;

    /* Intercept all Google Analytic requests and respond with a 200 */
      .intercept((req, res) => res.sendStatus(200));

    /* Pass-through all GET requests to /coverage */

    /* start: pseudo test code */
    await visit('/login');
    await fillIn('email', '');
    await fillIn('password', '@pollyjs');
    await submit();
    /* end: pseudo test code */


      Calling `stop` will persist requests as well as disconnect from any
      connected browser APIs (e.g. fetch or XHR).
    await polly.stop();

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:

  "log": {
    "_recordingName": "Sign In",
    "browser": {
      "name": "Chrome",
      "version": "67.0"
    "creator": {
      "name": "Polly.JS",
      "version": "0.5.0",
      "comment": "persister:rest"
    "entries": [
        "_id": "06f06e6d125cbb80896c41786f9a696a",
        "_order": 0,
        "cache": {},
        "request": {
          "bodySize": 51,
          "cookies": [],
          "headers": [
              "name": "content-type",
              "value": "application/json; charset=utf-8"
          "headersSize": 97,
          "httpVersion": "HTTP/1.1",
          "method": "POST",
          "postData": {
            "mimeType": "application/json; charset=utf-8",
            "text": "{\"email\":\"\",\"password\":\"@pollyjs\"}"
          "queryString": [],
          "url": ""
        "response": {
          "bodySize": 0,
          "content": {
            "mimeType": "text/plain; charset=utf-8",
            "size": 0
          "cookies": [],
          "headers": [],
          "headersSize": 0,
          "httpVersion": "HTTP/1.1",
          "redirectURL": "",
          "status": 200,
          "statusText": "OK"
        "startedDateTime": "2018-06-29T17:31:55.348Z",
        "time": 11,
        "timings": {
          "blocked": -1,
          "connect": -1,
          "dns": -1,
          "receive": 0,
          "send": 0,
          "ssl": -1,
          "wait": 11
    "pages": [],
    "version": "1.2"


In alphabetical order:

We're hiring!

Join the Netflix Studio & Content Engineering teams to help us build projects like this!

Open Roles:


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

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.