File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ const { URL } = require('url');
77const JSONfn = require ( 'json-fn' ) ;
88const FastBoot = require ( 'fastboot' ) ;
99const bodyParser = require ( 'body-parser' ) ;
10+ const { deprecate } = require ( 'util' ) ;
1011
1112function createMockRequest ( app ) {
1213 app . post (
@@ -104,13 +105,15 @@ function makeFastbootTestingConfig(config, pkg) {
104105
105106 if ( fs . existsSync ( fastbootTestConfigPath ) ) {
106107 const fastbootTestConfig = require ( fastbootTestConfigPath ) ;
107- if ( typeof fastbootTestConfig !== 'function' ) {
108- throw new Error (
109- `Expected export of ${ fastbootTestConfigPath } to be a function. Instead found (${ typeof fastbootTestConfig } ).`
110- ) ;
111- }
112108
113- customized = fastbootTestConfig ( ) ;
109+ if ( typeof fastbootTestConfig === 'function' ) {
110+ customized = fastbootTestConfig ( ) ;
111+ } else {
112+ deprecate (
113+ ( ) => Object . assign ( customized , fastbootTestConfig ) ,
114+ `Exporting an object from ${ fastbootTestConfigPath } has been deprecated. Please export a function which returns an object instead.` ,
115+ ) ( ) ;
116+ }
114117 }
115118
116119 return Object . assign ( { } , config , defaults , customized ) ;
You can’t perform that action at this time.
0 commit comments