Nock Cheat Sheet

From WikiOD

Here is the cheatsheat of Nock and basic guide on how to use Nock

Nock[edit | edit source]

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

Filtering[edit | edit source]

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

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

Credit:rstacruz