@@ -918,6 +918,52 @@ test('match multiple interceptors with regexp domain', async t => {
918918 } )
919919} )
920920
921+ test ( 'interceptors should work in any order' , async t => {
922+ nock ( 'http://some.test' )
923+ . get ( '/path1?query=1' )
924+ . reply ( 200 , 'response for path1/query1' )
925+ . get ( '/path2?query=2' )
926+ . reply ( 200 , 'response for path2/query2' )
927+
928+ // Calling second request before first
929+ const response2 = await got ( 'http://some.test/path2?query=2' )
930+ expect ( response2 ) . to . include ( {
931+ statusCode : 200 ,
932+ body : 'response for path2/query2' ,
933+ } )
934+
935+ // Calling first request after second
936+ const response1 = await got ( 'http://some.test/path1?query=1' )
937+ expect ( response1 ) . to . include ( {
938+ statusCode : 200 ,
939+ body : 'response for path1/query1' ,
940+ } )
941+ } )
942+
943+ test ( 'interceptors should work in any order with filteringScope' , async t => {
944+ nock ( 'http://some.test' , {
945+ filteringScope : scope => true ,
946+ } )
947+ . get ( '/path1?query=1' )
948+ . reply ( 200 , 'response for path1/query1' )
949+ . get ( '/path2?query=2' )
950+ . reply ( 200 , 'response for path2/query2' )
951+
952+ // Calling second request before first
953+ const response2 = await got ( 'http://other.test/path2?query=2' )
954+ expect ( response2 ) . to . include ( {
955+ statusCode : 200 ,
956+ body : 'response for path2/query2' ,
957+ } )
958+
959+ // Calling first request after second
960+ const response1 = await got ( 'http://other.test/path1?query=1' )
961+ expect ( response1 ) . to . include ( {
962+ statusCode : 200 ,
963+ body : 'response for path1/query1' ,
964+ } )
965+ } )
966+
921967// FIXME: This marked as { todo: true } because it is an existing bug.
922968// https://github.com/nock/nock/issues/1108
923969test (
0 commit comments