Netflix/pollyjs là dự án JavaScript với 10.2k sao trong nhóm Frontend. Record, Replay, and Stub HTTP Interactions.
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
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:
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.
Netflix/pollyjs thuộc nhóm Frontend trên TopGit, cùng 7 topic GitHub. Trang Trending và Topics liệt kê các repo cùng số sao và cùng ngôn ngữ để so sánh.
Đọc thêm về Netflix/pollyjs ở đâu?
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/Netflix/pollyjs là nguồn chính thức.
Netflix/pollyjs có bao nhiêu sao?
Netflix/pollyjs có 10.2k sao GitHub — tải lại trang để xem số mới nhất, hoặc xem trực tiếp github.com/Netflix/pollyjs. TopGit phản chiếu số sao của GitHub nhưng không cam kết đến từng phút.
Netflix/pollyjs có phải mã nguồn mở không?
Có — Netflix/pollyjs phát hành theo license Apache-2.0, nghĩa là mã nguồn mở để đọc, fork và (tùy license) tái sử dụng. Mã: github.com/Netflix/pollyjs.
Netflix/pollyjs có trang demo không?
Dự án có trang chủ ở https://netflix.github.io/pollyjs. Tab "Readme" ở trang này thường có ảnh chụp và hướng dẫn bắt đầu nhanh.
Netflix/pollyjs là gì?
Netflix/pollyjs (Netflix/pollyjs) là dự án JavaScript trên GitHub. Theo mô tả gốc: Record, Replay, and Stub HTTP Interactions.
Netflix/pollyjs so với các dự án Frontend khác thế nào?
Netflix/pollyjs được TopGit xếp vào nhóm Frontend, với 10.2k sao GitHub và viết bằng JavaScript. Xem trang chủ đề Frontend trên TopGit để so sánh với các dự án tương tự theo số sao và mức độ hoạt động.
Đọc đầy đủ README ở tab phía trên.
pollyjs có đáng để bạn bỏ thời gian?
ChatGPT, Claude và Perplexity đều đọc được trang này. Hỏi thử xem họ nghĩ gì về pollyjs.