File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change 22
33const fs = require ( 'fs' ) ;
44const path = require ( 'path' ) ;
5- const nock = require ( 'nock' ) ;
65const { URL } = require ( 'url' ) ;
76const JSONfn = require ( 'json-fn' ) ;
87const FastBoot = require ( 'fastboot' ) ;
98const bodyParser = require ( 'body-parser' ) ;
109const { deprecate } = require ( 'util' ) ;
1110
11+ let _nock ;
12+ function getNock ( ) {
13+ if ( ! _nock ) {
14+ _nock = require ( 'nock' ) ;
15+ }
16+ return _nock ;
17+ }
18+
1219function createMockRequest ( app ) {
1320 app . post (
1421 '/__mock-request' ,
1522 bodyParser . json ( { limit : '50mb' } ) ,
1623 ( req , res ) => {
1724 const requestOrigin = req . body . origin || req . headers . origin ;
18- let mock = nock ( requestOrigin )
25+ let mock = getNock ( ) ( requestOrigin )
1926 . persist ( )
2027 . intercept ( req . body . path , req . body . method )
2128 . reply (
@@ -31,7 +38,7 @@ function createMockRequest(app) {
3138
3239function createCleanUpMocks ( app ) {
3340 app . use ( '/__cleanup-mocks' , ( req , res ) => {
34- nock . cleanAll ( ) ;
41+ getNock ( ) . cleanAll ( ) ;
3542
3643 res . json ( { ok : true } ) ;
3744 } ) ;
You can’t perform that action at this time.
0 commit comments