@@ -154,7 +154,8 @@ describe('packExternalModules', () => {
154154
155155 it ( 'should do nothing if webpackIncludeModules is not set' , ( ) => {
156156 _ . unset ( serverless , 'service.custom.webpackIncludeModules' ) ;
157- return expect ( module . packExternalModules ( { stats : [ ] } ) ) . to . eventually . deep . equal ( { stats : [ ] } )
157+ module . compileStats = { stats : [ ] } ;
158+ return expect ( module . packExternalModules ( ) ) . to . be . fulfilled
158159 . then ( ( ) => BbPromise . all ( [
159160 expect ( fsExtraMock . copy ) . to . not . have . been . called ,
160161 expect ( childProcessMock . exec ) . to . not . have . been . called ,
@@ -188,7 +189,8 @@ describe('packExternalModules', () => {
188189 childProcessMock . exec . onFirstCall ( ) . yields ( null , '{}' , '' ) ;
189190 childProcessMock . exec . onSecondCall ( ) . yields ( null , '' , '' ) ;
190191 childProcessMock . exec . onThirdCall ( ) . yields ( ) ;
191- return expect ( module . packExternalModules ( stats ) ) . to . be . fulfilled
192+ module . compileStats = stats ;
193+ return expect ( module . packExternalModules ( ) ) . to . be . fulfilled
192194 . then ( ( ) => BbPromise . all ( [
193195 // The module package JSON and the composite one should have been stored
194196 expect ( writeFileSyncStub ) . to . have . been . calledTwice ,
@@ -217,7 +219,8 @@ describe('packExternalModules', () => {
217219 childProcessMock . exec . onFirstCall ( ) . yields ( null , '{}' , '' ) ;
218220 childProcessMock . exec . onSecondCall ( ) . yields ( new Error ( 'npm install failed' ) ) ;
219221 childProcessMock . exec . onThirdCall ( ) . yields ( ) ;
220- return expect ( module . packExternalModules ( stats ) ) . to . be . rejectedWith ( 'npm install failed' )
222+ module . compileStats = stats ;
223+ return expect ( module . packExternalModules ( ) ) . to . be . rejectedWith ( 'npm install failed' )
221224 . then ( ( ) => BbPromise . all ( [
222225 // npm ls and npm install should have been called
223226 expect ( childProcessMock . exec ) . to . have . been . calledTwice ,
@@ -230,7 +233,8 @@ describe('packExternalModules', () => {
230233 fsExtraMock . pathExists . yields ( null , false ) ;
231234 fsExtraMock . copy . yields ( ) ;
232235 childProcessMock . exec . yields ( new Error ( 'something went wrong' ) , '{}' , stderr ) ;
233- return expect ( module . packExternalModules ( stats ) ) . to . be . rejectedWith ( 'something went wrong' )
236+ module . compileStats = stats ;
237+ return expect ( module . packExternalModules ( ) ) . to . be . rejectedWith ( 'something went wrong' )
234238 . then ( ( ) => BbPromise . all ( [
235239 // The module package JSON and the composite one should have been stored
236240 expect ( writeFileSyncStub ) . to . not . have . been . called ,
@@ -250,7 +254,8 @@ describe('packExternalModules', () => {
250254 fsExtraMock . pathExists . yields ( null , false ) ;
251255 fsExtraMock . copy . yields ( ) ;
252256 childProcessMock . exec . yields ( new Error ( 'something went wrong' ) , '{}' , stderr ) ;
253- return expect ( module . packExternalModules ( stats ) ) . to . be . rejectedWith ( 'something went wrong' )
257+ module . compileStats = stats ;
258+ return expect ( module . packExternalModules ( ) ) . to . be . rejectedWith ( 'something went wrong' )
254259 . then ( ( ) => BbPromise . all ( [
255260 // The module package JSON and the composite one should have been stored
256261 expect ( writeFileSyncStub ) . to . not . have . been . called ,
@@ -311,7 +316,8 @@ describe('packExternalModules', () => {
311316 childProcessMock . exec . onFirstCall ( ) . yields ( new Error ( 'NPM error' ) , JSON . stringify ( lsResult ) , stderr ) ;
312317 childProcessMock . exec . onSecondCall ( ) . yields ( null , '' , '' ) ;
313318 childProcessMock . exec . onThirdCall ( ) . yields ( ) ;
314- return expect ( module . packExternalModules ( stats ) ) . to . be . fulfilled
319+ module . compileStats = stats ;
320+ return expect ( module . packExternalModules ( ) ) . to . be . fulfilled
315321 . then ( ( ) => BbPromise . all ( [
316322 // The module package JSON and the composite one should have been stored
317323 expect ( writeFileSyncStub ) . to . have . been . calledTwice ,
@@ -338,9 +344,9 @@ describe('packExternalModules', () => {
338344 module . webpackOutputPath = 'outputPath' ;
339345 fsExtraMock . copy . yields ( ) ;
340346 childProcessMock . exec . yields ( null , '{}' , '' ) ;
341- return expect ( module . packExternalModules ( noExtStats ) ) . to . be . fulfilled
342- . then ( stats => BbPromise . all ( [
343- expect ( stats ) . to . deep . equal ( noExtStats ) ,
347+ module . compileStats = noExtStats ;
348+ return expect ( module . packExternalModules ( ) ) . to . be . fulfilled
349+ . then ( ( ) => BbPromise . all ( [
344350 // The module package JSON and the composite one should have been stored
345351 expect ( writeFileSyncStub ) . to . not . have . been . called ,
346352 // The modules should have been copied
@@ -382,7 +388,8 @@ describe('packExternalModules', () => {
382388 childProcessMock . exec . onFirstCall ( ) . yields ( null , '{}' , '' ) ;
383389 childProcessMock . exec . onSecondCall ( ) . yields ( null , '' , '' ) ;
384390 childProcessMock . exec . onThirdCall ( ) . yields ( ) ;
385- return expect ( module . packExternalModules ( stats ) ) . to . be . fulfilled
391+ module . compileStats = stats ;
392+ return expect ( module . packExternalModules ( ) ) . to . be . fulfilled
386393 . then ( ( ) => BbPromise . all ( [
387394 // The module package JSON and the composite one should have been stored
388395 expect ( writeFileSyncStub ) . to . have . been . calledTwice ,
@@ -436,7 +443,8 @@ describe('packExternalModules', () => {
436443 childProcessMock . exec . onFirstCall ( ) . yields ( null , '{}' , '' ) ;
437444 childProcessMock . exec . onSecondCall ( ) . yields ( null , '' , '' ) ;
438445 childProcessMock . exec . onThirdCall ( ) . yields ( ) ;
439- return expect ( module . packExternalModules ( stats ) ) . to . be . fulfilled
446+ module . compileStats = stats ;
447+ return expect ( module . packExternalModules ( ) ) . to . be . fulfilled
440448 . then ( ( ) => BbPromise . all ( [
441449 // The module package JSON and the composite one should have been stored
442450 expect ( writeFileSyncStub ) . to . have . been . calledTwice ,
@@ -489,7 +497,8 @@ describe('packExternalModules', () => {
489497 childProcessMock . exec . onFirstCall ( ) . yields ( null , '{}' , '' ) ;
490498 childProcessMock . exec . onSecondCall ( ) . yields ( null , '' , '' ) ;
491499 childProcessMock . exec . onThirdCall ( ) . yields ( ) ;
492- return expect ( module . packExternalModules ( stats ) ) . to . be . fulfilled
500+ module . compileStats = stats ;
501+ return expect ( module . packExternalModules ( ) ) . to . be . fulfilled
493502 . then ( ( ) => BbPromise . all ( [
494503 // The module package JSON and the composite one should have been stored
495504 expect ( writeFileSyncStub ) . to . have . been . calledTwice ,
@@ -537,7 +546,8 @@ describe('packExternalModules', () => {
537546 childProcessMock . exec . onFirstCall ( ) . yields ( null , '{}' , '' ) ;
538547 childProcessMock . exec . onSecondCall ( ) . yields ( null , '' , '' ) ;
539548 childProcessMock . exec . onThirdCall ( ) . yields ( ) ;
540- return expect ( module . packExternalModules ( stats ) ) . to . be . fulfilled
549+ module . compileStats = stats ;
550+ return expect ( module . packExternalModules ( ) ) . to . be . fulfilled
541551 . then ( ( ) => BbPromise . all ( [
542552 // The module package JSON and the composite one should have been stored
543553 expect ( writeFileSyncStub ) . to . have . been . calledTwice ,
@@ -589,7 +599,8 @@ describe('packExternalModules', () => {
589599 childProcessMock . exec . onFirstCall ( ) . yields ( null , '{}' , '' ) ;
590600 childProcessMock . exec . onSecondCall ( ) . yields ( null , '' , '' ) ;
591601 childProcessMock . exec . onThirdCall ( ) . yields ( ) ;
592- return expect ( module . packExternalModules ( stats ) ) . to . be . fulfilled
602+ module . compileStats = stats ;
603+ return expect ( module . packExternalModules ( ) ) . to . be . fulfilled
593604 . then ( ( ) => BbPromise . all ( [
594605 // The module package JSON and the composite one should have been stored
595606 expect ( writeFileSyncStub ) . to . have . been . calledTwice ,
@@ -671,7 +682,8 @@ describe('packExternalModules', () => {
671682 childProcessMock . exec . onFirstCall ( ) . yields ( null , JSON . stringify ( dependencyGraph ) , '' ) ;
672683 childProcessMock . exec . onSecondCall ( ) . yields ( null , '' , '' ) ;
673684 childProcessMock . exec . onThirdCall ( ) . yields ( ) ;
674- return expect ( module . packExternalModules ( peerDepStats ) ) . to . be . fulfilled
685+ module . compileStats = peerDepStats ;
686+ return expect ( module . packExternalModules ( ) ) . to . be . fulfilled
675687 . then ( ( ) => BbPromise . all ( [
676688 // The module package JSON and the composite one should have been stored
677689 expect ( writeFileSyncStub ) . to . have . been . calledTwice ,
0 commit comments