Skip to content

Commit

Permalink
e2e: close ANR popup in case if exception happened
Browse files Browse the repository at this point in the history
  • Loading branch information
kirillzyusko committed Nov 6, 2024
1 parent 657531f commit 1fa5412
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tests/e2e/testRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import compare from './compare/compare';
import defaultConfig from './config';
import createServerInstance from './server';
import reversePort from './utils/androidReversePort';
import closeANRPopup from './utils/closeANRPopup';
import installApp from './utils/installApp';
import killApp from './utils/killApp';
import launchApp from './utils/launchApp';
Expand Down Expand Up @@ -287,6 +288,7 @@ const runTests = async (): Promise<void> => {
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
Logger.error(`Warmup failed with error: ${e}`);

closeANRPopup();
MeasureUtils.stop('error-warmup');
server.clearAllTestDoneListeners();

Expand Down Expand Up @@ -314,6 +316,7 @@ const runTests = async (): Promise<void> => {
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
Logger.error(`Unexpected error during test execution: ${e}. `);
MeasureUtils.stop('error');
closeANRPopup();
server.clearAllTestDoneListeners();
errorCountRef.errorCount += 1;
if (testIteration === 0 || errorCountRef.errorCount === errorCountRef.allowedExceptions) {
Expand Down
13 changes: 13 additions & 0 deletions tests/e2e/utils/closeANRPopup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import execAsync from './execAsync';
import type {PromiseWithAbort} from './execAsync';

const closeANRPopup = function (platform = 'android'): PromiseWithAbort {
if (platform !== 'android') {
throw new Error(`closeANRPopup() missing implementation for platform: ${platform}`);
}

// Press "Enter" to close the ANR popup
return execAsync(`adb shell input keyevent KEYCODE_ENTER`);
};

export default closeANRPopup;

0 comments on commit 1fa5412

Please sign in to comment.