Cheat Sheet速查表
跳转到主要内容

Nock 速查表

本文根据 Devhints / Nock 翻译。代码示例及版本范围沿用原文。

Nock

scope = nock('http://foo.com')
scope = nock('http://foo.com', { allowUnmocked: true })
nock('http://foo.com')
  .get('/user')
  .reply(200, { id: 1234 })

过滤

nock('http://foo.com')
  .filteringPath(/[&\?]token=[^&]*/g, '')
  .get('/user')

// catches "/user?token=..." as well