nock: update layout

This commit is contained in:
Rico Sta. Cruz 2018-02-20 00:10:17 +08:00
parent a45f46935b
commit c59095af32
No known key found for this signature in database
GPG Key ID: CAAD38AE2962619A
1 changed files with 16 additions and 10 deletions

26
nock.md
View File

@ -1,22 +1,28 @@
---
title: Nock
category: JavaScript libraries
layout: 2017/sheet
---
### Nock
scope = nock('http://foo.com')
scope = nock('http://foo.com', { allowUnmocked: true })
nock('http://foo.com')
.get('/user')
.reply(200, { id: 1234 })
```js
scope = nock('http://foo.com')
scope = nock('http://foo.com', { allowUnmocked: true })
```
```js
nock('http://foo.com')
.get('/user')
.reply(200, { id: 1234 })
```
### Filtering
nock('http://foo.com')
.filteringPath(/[&\?]token=[^&]*/g, '')
.get('/user')
```js
nock('http://foo.com')
.filteringPath(/[&\?]token=[^&]*/g, '')
.get('/user')
# catches "/user?token=..." as well
// catches "/user?token=..." as well
```