All Projects → Netflix → Pollyjs

Netflix / Pollyjs

Licence: apache-2.0
Record, Replay, and Stub HTTP Interactions.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Pollyjs

Pyinstalive
Python script to download Instagram livestreams and replays.
Stars: ✭ 336 (-96.46%)
Mutual labels:  record, replay
Noel
A universal, human-centric, replayable javascript event emitter.
Stars: ✭ 158 (-98.33%)
Mutual labels:  replay, browser
Buffer
The buffer module from node.js, for the browser.
Stars: ✭ 1,178 (-87.58%)
Mutual labels:  browser
Beef Over Wan
Browser Exploitation Framework is a Open-source penetration testing tool that focuses on browser-based vulnerabilities .This Python Script does the changes Required to make hooked Linked Accessible Over WAN .So anyone can use this framework and Attack Over WAN without Port Forwarding [NGROK or any Localhost to Webhost Service Required ]
Stars: ✭ 82 (-99.14%)
Mutual labels:  browser
Noduino
JavaScript and Node.js Framework for controlling Arduino with HTML and WebSockets
Stars: ✭ 1,202 (-87.33%)
Mutual labels:  browser
Vimperator Labs
Vimperator
Stars: ✭ 1,184 (-87.52%)
Mutual labels:  browser
Term Web
📟 A simple Terminal UI that run on the web
Stars: ✭ 77 (-99.19%)
Mutual labels:  browser
Apy
Apy is a simple client-side library for making rest api ajax calls.
Stars: ✭ 68 (-99.28%)
Mutual labels:  browser
Testcafe
A Node.js tool to automate end-to-end web testing.
Stars: ✭ 9,176 (-3.25%)
Mutual labels:  browser
String To Stream
Convert a string into a stream (streams2)
Stars: ✭ 75 (-99.21%)
Mutual labels:  browser
Browser Fuzz Summarize
Browser Fuzz Summarize / 浏览器模糊测试综述
Stars: ✭ 80 (-99.16%)
Mutual labels:  browser
Swiftype Search Jquery
Elastic Site Search jQuery search plugin
Stars: ✭ 74 (-99.22%)
Mutual labels:  browser
Bandersnatch
Black Mirror: Bandersnatch, HTML5 interactive version
Stars: ✭ 74 (-99.22%)
Mutual labels:  netflix
Shadowreplay Linux
Shadowplay's Replay Feature On Linux For Nvidia, AMD and Intel
Stars: ✭ 79 (-99.17%)
Mutual labels:  replay
Bittorrent Tracker
🌊 Simple, robust, BitTorrent tracker (client & server) implementation
Stars: ✭ 1,184 (-87.52%)
Mutual labels:  browser
Front End Resource Collection
前后端日常总结
Stars: ✭ 82 (-99.14%)
Mutual labels:  browser
Qrious
Pure JavaScript library for QR code generation using canvas
Stars: ✭ 1,160 (-87.77%)
Mutual labels:  browser
Neutronium
🚀 Build .NET desktop applications using HTML, CSS and javascript.
Stars: ✭ 1,190 (-87.45%)
Mutual labels:  browser
Macho Browser
Mac browser for Mach-O binaries (macOS, iOS, watchOS, and tvOS)
Stars: ✭ 77 (-99.19%)
Mutual labels:  browser
Brave Browser
Next generation Brave browser for Android, Linux, macOS, Windows.
Stars: ✭ 11,580 (+22.1%)
Mutual labels:  browser

Polly.JS

Record, Replay, and Stub HTTP Interactions

Build Status license

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.

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.
*/
Polly.register(XHRAdapter);
Polly.register(FetchAdapter);
Polly.register(RESTPersister);

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 */
    server
      .get('/google-analytics/*path')
      .intercept((req, res) => res.sendStatus(200));

    /* Pass-through all GET requests to /coverage */
    server.get('/coverage').passthrough();

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

    expect(location.pathname).to.equal('/browse');

    /*
      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\":\"[email protected]\",\"password\":\"@pollyjs\"}"
          },
          "queryString": [],
          "url": "https://netflix.com/api/v1/login"
        },
        "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"
  }
}

Credits

In alphabetical order:

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

We're hiring!

Join the Netflix Studio UI team to help us build projects like this! You can check out our open roles here on our team page.

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].