Skip to content

Commit

Permalink
Merge pull request #37004 from VickyStash/ts-migration/installApp-test
Browse files Browse the repository at this point in the history
[No QA] [TS migration] Migrate 'installApp.js' test to TypeScript
  • Loading branch information
pecanoro authored Mar 4, 2024
2 parents dd457d5 + 77b486a commit 982e2ee
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 28 deletions.
4 changes: 2 additions & 2 deletions tests/e2e/testRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ try {

const runTests = async () => {
Logger.info('Installing apps and reversing port');
await installApp('android', config.MAIN_APP_PACKAGE, mainAppPath);
await installApp('android', config.DELTA_APP_PACKAGE, deltaAppPath);
await installApp(config.MAIN_APP_PACKAGE, mainAppPath);
await installApp(config.DELTA_APP_PACKAGE, deltaAppPath);
await reversePort();

// Start the HTTP server
Expand Down
26 changes: 0 additions & 26 deletions tests/e2e/utils/installApp.js

This file was deleted.

25 changes: 25 additions & 0 deletions tests/e2e/utils/installApp.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import type {ExecException} from 'child_process';
import execAsync from './execAsync';
import type {PromiseWithAbort} from './execAsync';
import * as Logger from './logger';

/**
* Installs the app on the currently connected device for the given platform.
* It removes the app first if it already exists, so it's a clean installation.
*/
export default function (packageName: string, path: string, platform = 'android'): PromiseWithAbort {
if (platform !== 'android') {
throw new Error(`installApp() missing implementation for platform: ${platform}`);
}

// Uninstall first, then install
return (
execAsync(`adb uninstall ${packageName}`)
.catch((error: ExecException) => {
// Ignore errors
Logger.warn('Failed to uninstall app:', error);
})
// eslint-disable-next-line @typescript-eslint/no-misused-promises
.finally(() => execAsync(`adb install ${path}`))
);
}

0 comments on commit 982e2ee

Please sign in to comment.