11import { Yok } from "../../../lib/common/yok" ;
22import { WebpackCompilerService } from "../../../lib/services/webpack/webpack-compiler-service" ;
33import { assert } from "chai" ;
4+ import { ErrorsStub } from "../../stubs" ;
45
56const iOSPlatformName = "ios" ;
67const androidPlatformName = "android" ;
@@ -17,10 +18,13 @@ function createTestInjector(): IInjector {
1718 testInjector . register ( "hooksService" , { } ) ;
1819 testInjector . register ( "hostInfo" , { } ) ;
1920 testInjector . register ( "logger" , { } ) ;
20- testInjector . register ( "errors" , { } ) ;
21+ testInjector . register ( "errors" , ErrorsStub ) ;
2122 testInjector . register ( "packageInstallationManager" , { } ) ;
2223 testInjector . register ( "mobileHelper" , { } ) ;
2324 testInjector . register ( "cleanupService" , { } ) ;
25+ testInjector . register ( "fs" , {
26+ exists : ( filePath : string ) => true
27+ } ) ;
2428
2529 return testInjector ;
2630}
@@ -87,4 +91,22 @@ describe("WebpackCompilerService", () => {
8791 assert . deepEqual ( androidResult . emittedFiles , [ "bundle.hash6.hot-update.js" , "hash6.hot-update.json" ] ) ;
8892 } ) ;
8993 } ) ;
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+ } ) ;
90112} ) ;
0 commit comments