可记录、重放和存根 HTTP 交互的 JavaScript 库 Polly.JS

码农软件 · 软件分类 · 常用JavaScript包 · 2019-04-04 15:29:41

软件介绍

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();
  });
});

本文地址:https://codercto.com/soft/d/2849.html

界面设计模式

界面设计模式

Jenifer Tidwell / 东南大学,O‘Reilly / 2011-5 / 99.00元

尽管目前已经存在了各种各样的用户界面设计工具,设计良好的应用界面仍然不是一件容易的事情。这本畅销书是极少数可以信赖的资料,它能帮助你走出设计选项的迷宫。通过把捕捉到的最佳实践和重用思想体现为设计模式,《界面设计模式》提供了针对常见设计问题的解决方案,这些方案可以被裁减以适用于你的具体情况。本修订版包括了手机应用和社交媒体的模式,以及web应用和桌面软件。每个模式包含了用全彩方式展现的运用技巧,以及......一起来看看 《界面设计模式》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

在线进制转换器
在线进制转换器

各进制数互转换器

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具