OSDN Git Service

Regular updates
[twpd/master.git] / nock.md
1 ---
2 title: Nock
3 category: JavaScript libraries
4 layout: 2017/sheet
5 ---
6
7 ### Nock
8
9 ```js
10 scope = nock('http://foo.com')
11 scope = nock('http://foo.com', { allowUnmocked: true })
12 ```
13
14 ```js
15 nock('http://foo.com')
16   .get('/user')
17   .reply(200, { id: 1234 })
18 ```
19
20 ### Filtering
21
22 ```js
23 nock('http://foo.com')
24   .filteringPath(/[&\?]token=[^&]*/g, '')
25   .get('/user')
26
27 // catches "/user?token=..." as well
28 ```