shot

2018-11-08 admin

shot是什么

什么是shot,Injects a fake HTTP request/response into a node HTTP server

shot使用教程帮助文档

shot Logo

Injects a fake HTTP request/response into a node HTTP server for simulating server logic, writing tests, or debugging. Does not use a socket connection so can be run against an inactive server (server not in listen mode).

Build Status

Lead Maintainer: Matt Harrison

Example

// Load modules

const Http = require('http');
const Shot = require('shot');

// Declare internals

const internals = {};

internals.main = async function () {

    const dispatch = function (req, res) {

        const reply = 'Hello World';
        res.writeHead(200, { 'Content-Type': 'text/plain', 'Content-Length': reply.length });
        res.end(reply);
    };

    const server = Http.createServer(dispatch);

    const res = await Shot.inject(dispatch, { method: 'get', url: '/' });
    console.log(res.payload);
};

internals.main();

Note how server.listen is never called.

API

See the API Reference

本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处。

转载请注明:文章转载自 JavaScript中文网 [https://www.javascriptcn.com]

本文地址:https://www.javascriptcn.com/read-44893.html

文章标题:shot

相关文章
How can I refresh a stored and snapshotted jquery selector variable
Ralk提出了一个问题:How can I refresh a stored and snapshotted jquery selector variable,或许与您遇到的问题类似。 回答者Esailija给出了该问题的处理方式: Yea...
2018-04-24
snap-shot-core
snap-shot-core是什么 什么是snap-shot-core,Save / load named snapshots, useful for tests snap-shot-core官网:官网 snap-shot-core源码仓...
2018-11-22
jest-specific-snapshot
jest-specific-snapshot是什么 什么是jest-specific-snapshot,Jest matcher for multiple snapshot files per test jest-specific-sna...
2019-02-26
在Vue项目中使用snapshot测试
snapshot介绍 snapshot测试又称快照测试,可以直观地反映出组件UI是否发生了未预见到的变化。snapshot如字面上所示,直观描述出组件的样子。通过对比前后的快照,可以很快找出UI的变化之处。 第一次运行快照测试时会生成一个快...
2018-12-29
jest-snapshot-serializer-ansi
jest-snapshot-serializer-ansi是什么 什么是jest-snapshot-serializer-ansi,jest snapshot serializer for stripping ANSI escape cod...
2019-01-23
schema-shot
schema-shot是什么 什么是schema-shot,Framework-agnostic snapshot testing using 'schema by example' for highly dynamic data sch...
2018-11-20
rollup-plugin-size-snapshot
rollup-plugin-size-snapshot是什么 什么是rollup-plugin-size-snapshot,[travis-img]: https://travis-ci.org/TrySound/rollup-plugin...
2018-10-01
jest-image-snapshot
jest-image-snapshot是什么 什么是jest-image-snapshot,Jest matcher for image comparisons. Most commonly used for visual regressi...
2019-03-10
webshot
webshot是什么 什么是webshot,Easy website screenshots webshot官网:官网 webshot源码仓库:源码仓库 webshot下载地址:点此下载 点此下载2 webshot使用教程帮助文档 n...
2019-04-04
snapshotify
snapshotify是什么 什么是snapshotify,Creates a static HTML snapshot for your create-react-app app, to improve initial page load...
2019-04-19
回到顶部