@@ -243,22 +243,15 @@ var AndroidEmulatorManager = (function () {
243243 */
244244 AndroidEmulatorManager . prototype . prepareEmulatorForTest = function ( appId ) {
245245 return this . endRunningApplication ( appId )
246- . then ( function ( ) { return testUtil_1 . TestUtil . getProcessOutput ( "adb shell pm clear " + appId ) ; } ) . then ( function ( ) { return null ; } ) ;
246+ . then ( function ( ) {
247+ return commandWithCheckAppExistence ( "adb shell pm clear" , appId ) ;
248+ } ) ;
247249 } ;
248250 /**
249251 * Uninstalls the app from the emulator.
250252 */
251253 AndroidEmulatorManager . prototype . uninstallApplication = function ( appId ) {
252- return testUtil_1 . TestUtil . getProcessOutput ( "adb shell pm list packages" )
253- . then ( function ( output ) {
254- return output . includes ( appId ) ;
255- } ) . then ( function ( isAppExist ) {
256- if ( isAppExist ) {
257- return testUtil_1 . TestUtil . getProcessOutput ( "adb uninstall " + appId ) . then ( function ( ) { return null ; } ) ;
258- }
259-
260- return null ;
261- } ) ;
254+ return commandWithCheckAppExistence ( "adb uninstall" , appId ) ;
262255 } ;
263256 AndroidEmulatorManager . ANDROID_EMULATOR_OPTION_NAME = "--androidemu" ;
264257 AndroidEmulatorManager . DEFAULT_ANDROID_EMULATOR = "emulator" ;
@@ -398,3 +391,16 @@ var IOSEmulatorManager = (function () {
398391 return IOSEmulatorManager ;
399392} ( ) ) ;
400393exports . IOSEmulatorManager = IOSEmulatorManager ;
394+
395+ function commandWithCheckAppExistence ( command , appId ) {
396+ return testUtil_1 . TestUtil . getProcessOutput ( "adb shell pm list packages" , { noLogCommand : true , noLogStdOut : true , noLogStdErr : true } )
397+ . then ( ( output ) => {
398+ return output . includes ( appId ) ;
399+ } ) . then ( ( isAppExist ) => {
400+ if ( isAppExist ) {
401+ return testUtil_1 . TestUtil . getProcessOutput ( `${ command } ${ appId } ` ) . then ( function ( ) { return null ; } ) ;
402+ }
403+ console . log ( `Command "${ command } " is skipped because the application has not yet been installed` )
404+ return null ;
405+ } ) ;
406+ }
0 commit comments