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

相关文章
snapshot
snapshot是什么 什么是snapshot,Serialize circular references, custom objects and other types not supported by JSON snapshot官网:...
2018-12-19
三行CSS代码搞定镜头平移(Panning Shot)动画
什么是镜头平移,一目了然看下图的镜头效果: 在视频场景中,经常需要实现镜头平移的效果,摄影术语上这叫做Panning Shot,动画中实现镜头平移效果的方法很多种,比如在codepen中搜了下,就找到一个利用 background-pos...
2018-12-05
schema-shot
schema-shot是什么 什么是schema-shot,Framework-agnostic snapshot testing using 'schema by example' for highly dynamic data sch...
2018-11-20
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
rollup-plugin-size-snapshot
rollup-plugin-size-snapshot是什么 什么是rollup-plugin-size-snapshot,[travis-img]: https://travis-ci.org/TrySound/rollup-plugin...
2018-10-01
在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
回到顶部