File tree Expand file tree Collapse file tree 2 files changed +21
-14
lines changed
Expand file tree Collapse file tree 2 files changed +21
-14
lines changed Original file line number Diff line number Diff line change 11'use strict' ;
22
3- let resolve = require ( 'resolve' ) ;
4- let minimist = require ( 'minimist' ) ;
5-
6- let {
7- createCleanUpMocks,
8- createFastbootEcho,
9- createFastbootTest,
10- createMockRequest,
11- reloadServer,
12- createServer,
13- } = require ( './lib/helpers' ) ;
3+ const resolve = require ( 'resolve' ) ;
4+ const minimist = require ( 'minimist' ) ;
145
156module . exports = {
167 name : require ( './package' ) . name ,
@@ -48,6 +39,8 @@ module.exports = {
4839
4940 // we have to use the outputReady hook to ensure that ember-cli has finished copying the contents to the outputPath directory
5041 outputReady ( result ) {
42+ const { reloadServer, createServer } = require ( './lib/helpers' ) ;
43+
5144 const isEnabled =
5245 this . app . name === 'dummy' || this . app . env !== 'production' ;
5346
@@ -69,6 +62,13 @@ module.exports = {
6962 } ,
7063
7164 _fastbootRenderingMiddleware ( app ) {
65+ const {
66+ createCleanUpMocks,
67+ createFastbootEcho,
68+ createFastbootTest,
69+ createMockRequest,
70+ createServer,
71+ } = require ( './lib/helpers' ) ;
7272 createMockRequest ( app ) ;
7373 createCleanUpMocks ( app ) ;
7474 createFastbootTest ( app , ( { res, options, urlToVisit } ) => {
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