ts-mounte银行
一个简单的节点软件包,允许您管理您的 Mountebank 测试服务器。 。 。 . 根据https://www.npmjs.com/package/@toreaction/node-mountebank,但
- 更新/删除的脆弱包件,
- 更新代码和
- 添加创建非常简单的代理的能力
- 改进的上游(不仅仅是等同的)
使用量
预需
安装 Mountebank :
npm install -g mountebank --production
启动 Mountebank :
mb
我建议你读一下 挂载银行文档 更深入地了解他们的API.
更多关于如何使用此软件包的样本请检查此博客 : https://angela-evans.com/easy-api-tests- with-mountebank/ 互联网档案馆的存檔,存档日期2013-12-21 或综合测试.
创建出错
const mb = new Mountebank();
let imposter = new Imposter().withPort(port).withStub(
new DefaultStub(testPath, HttpMethod.GET, 'testbody', 222));
await mb.createImposter(imposter);
检查查询串
添加查询到 stub 中 。 关于用法,请检查./集成测试/predicate.flexi-predicate.query.mb-ts中的用法
new Stub()
.withPredicate(
new FlexiPredicate()
.withOperator(Operator.equals)
.withPath('/testpath')
.withQuery({name: 'x', max: 5})
)
.withResponse(new DefaultResponse('found', 222))
创建调试代理
一个总是代理请求并记录回复的简单代理. 这对
- 测试时调试流量或
- 记录APIs之间的流量,用作建模的模板.
// forward all requestsfrom port 5000 => 5001 and generate response stubs
let proxyImposter = new Imposter()
.withPort(5000)
.withStub(new Stub()
.withProxy(new DebugProxy(`http://localhost:5001}`)));
await mb.createImposter(proxyImposter);