Skip to content

Commit a700fa2

Browse files
authored
fix(types): DataMatcher to allow valid JSON scalars. (#1703)
Fixes: #1702
1 parent 9d5cda0 commit a700fa2

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

types/index.d.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,16 @@ declare namespace nock {
3737
interceptorOptions?: Options
3838
) => Interceptor
3939

40+
// essentially valid decoded JSON with the addition of possible RegExp
4041
interface DataMatcher {
4142
[k: string]:
43+
| boolean
44+
| null
45+
| number
4246
| string
4347
| RegExp
4448
| DataMatcher
45-
| Array<string | RegExp | DataMatcher>
49+
| Array<boolean | null | number | string | RegExp | DataMatcher>
4650
}
4751

4852
type RequestBodyMatcher =

types/tests.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,15 @@ scope = nock('http://example.test')
182182
rev: '946B7D1C',
183183
})
184184

185+
nock('https://example.test')
186+
.post('/path', {
187+
number: 1,
188+
bool: false,
189+
empty: null,
190+
array: ['foo', 2, true, null, { number: 3 }],
191+
})
192+
.reply(200)
193+
185194
scope = nock('http://example.test')
186195
.post('/users', /email=.?@example.test/gi)
187196
.reply(201, {

0 commit comments

Comments
 (0)