1
1
import { Yok } from "../../../lib/common/yok" ;
2
2
import { WebpackCompilerService } from "../../../lib/services/webpack/webpack-compiler-service" ;
3
3
import { assert } from "chai" ;
4
+ import { ErrorsStub } from "../../stubs" ;
4
5
5
6
const iOSPlatformName = "ios" ;
6
7
const androidPlatformName = "android" ;
@@ -17,10 +18,13 @@ function createTestInjector(): IInjector {
17
18
testInjector . register ( "hooksService" , { } ) ;
18
19
testInjector . register ( "hostInfo" , { } ) ;
19
20
testInjector . register ( "logger" , { } ) ;
20
- testInjector . register ( "errors" , { } ) ;
21
+ testInjector . register ( "errors" , ErrorsStub ) ;
21
22
testInjector . register ( "packageInstallationManager" , { } ) ;
22
23
testInjector . register ( "mobileHelper" , { } ) ;
23
24
testInjector . register ( "cleanupService" , { } ) ;
25
+ testInjector . register ( "fs" , {
26
+ exists : ( filePath : string ) => true
27
+ } ) ;
24
28
25
29
return testInjector ;
26
30
}
@@ -87,4 +91,22 @@ describe("WebpackCompilerService", () => {
87
91
assert . deepEqual ( androidResult . emittedFiles , [ "bundle.hash6.hot-update.js" , "hash6.hot-update.json" ] ) ;
88
92
} ) ;
89
93
} ) ;
94
+
95
+ describe ( "compileWithWatch" , ( ) => {
96
+ it ( "fails when the value set for webpackConfigPath is not existant file" , async ( ) => {
97
+ const webpackConfigPath = "some path.js" ;
98
+ testInjector . resolve ( "fs" ) . exists = ( filePath : string ) => filePath !== webpackConfigPath ;
99
+ await assert . isRejected ( webpackCompilerService . compileWithWatch ( < any > { platformNameLowerCase : "android" } , < any > { webpackConfigPath } , < any > { } ) ,
100
+ `The webpack configuration file ${ webpackConfigPath } does not exist. Ensure you have such file or set correct path in nsconfig.json` ) ;
101
+ } ) ;
102
+ } ) ;
103
+
104
+ describe ( "compileWithoutWatch" , ( ) => {
105
+ it ( "fails when the value set for webpackConfigPath is not existant file" , async ( ) => {
106
+ const webpackConfigPath = "some path.js" ;
107
+ testInjector . resolve ( "fs" ) . exists = ( filePath : string ) => filePath !== webpackConfigPath ;
108
+ await assert . isRejected ( webpackCompilerService . compileWithoutWatch ( < any > { platformNameLowerCase : "android" } , < any > { webpackConfigPath } , < any > { } ) ,
109
+ `The webpack configuration file ${ webpackConfigPath } does not exist. Ensure you have such file or set correct path in nsconfig.json` ) ;
110
+ } ) ;
111
+ } ) ;
90
112
} ) ;
0 commit comments