Polly.JS可记录、重放和存根 HTTP 交互的 JavaScript 库
Polly.JS 是 Netflix 开源的一个独立、框架无关的 JavaScript 库,可记录,重放和存根 HTTP 交互。
Polly 利用本地浏览器 API 轻松调试请求和响应,同时让你能够使用简单、功能强大且直观的 API 全面控制每个请求,这将便于后期模拟不同的应用状态(例如加载、报错等)。
功能特性
-
支持 Fetch & XHR
-
简单、强大 & 直观的 API
-
一流的 Mocha & QUnit 测试助手
-
拦截、传递和附加事件
-
记录到磁盘或本地存储
-
时间减速或加速
Usage
import { Polly } from '@pollyjs/core'; describe('Netflix Homepage', function() { it('should be able to sign in', async function() { /* Create a new polly instance. By default, Polly will connect to both fetch and XHR browser APIs and will record any requests that it hasn't yet seen while replaying ones it has already recorded. */ const polly = new Polly('Sign In'); 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', 'polly@netflix.com'); 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(); }); });
评论
PHP-VCRHTTP 交互记录
PHP-VCR可以记录你测试套件的HTTP交互,并且在今后运行更快、更准确的测试中重放。它有以下特点:以最少的设置/配置代码自动记录和重播HTTP交互。支持常见的http功能和扩展使用streamWr
PHP-VCRHTTP 交互记录
0
Elastomer-ClientElasticsearch 的交互库
Elastomer-Client为 ElasticSearchAPIendpoint提供一个一对一的映射。API通过你想要实现的来分解为逻辑部分和访问,每一个逻辑部分代表一个客户端类。示例代码:req
Elastomer-ClientElasticsearch 的交互库
0
Evmongoose可伸缩 HTTP 服务器库
Evmongoose是一个API接口友好和可伸缩的HTTP服务器库,它基于mongoose和libev实现。Evmongoose支持高度的可定制化来扩展你的应用程序。在开始这个项目之前,我一直都没有找
Evmongoose可伸缩 HTTP 服务器库
0
WerkzeugPython 的 HTTP 和 WSGI 工具库
Werkzeug 是一个 Python 的 HTTP 和 WSGI 工具库,可以方便的在 Pytho
WerkzeugPython 的 HTTP 和 WSGI 工具库
0