File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -350,7 +350,8 @@ function interceptorScopes() {
350350 const nestedInterceptors = Object . values ( allInterceptors ) . map (
351351 i => i . interceptors ,
352352 )
353- return [ ] . concat ( ...nestedInterceptors ) . map ( i => i . scope )
353+ const scopes = new Set ( [ ] . concat ( ...nestedInterceptors ) . map ( i => i . scope ) )
354+ return [ ...scopes ]
354355}
355356
356357function isDone ( ) {
Original file line number Diff line number Diff line change @@ -163,6 +163,22 @@ describe('Nock lifecycle functions', () => {
163163 await got ( 'http://example.test/' )
164164 expect ( nock . activeMocks ( ) ) . to . be . empty ( )
165165 } )
166+
167+ it ( "activeMocks doesn't return duplicate mocks" , ( ) => {
168+ nock ( 'http://example.test' )
169+ . get ( '/' )
170+ . reply ( )
171+ . get ( '/second' )
172+ . reply ( )
173+ . get ( '/third' )
174+ . reply ( )
175+
176+ expect ( nock . activeMocks ( ) ) . to . deep . equal ( [
177+ 'GET http://example.test:80/' ,
178+ 'GET http://example.test:80/second' ,
179+ 'GET http://example.test:80/third' ,
180+ ] )
181+ } )
166182 } )
167183
168184 describe ( 'resetting nock catastrophically while a request is in progress' , ( ) => {
You can’t perform that action at this time.
0 commit comments