From 2fcd8df259a014d586431e562a8b7c0d9d6e4f25 Mon Sep 17 00:00:00 2001 From: kirillzyusko Date: Mon, 22 Apr 2024 14:33:07 +0200 Subject: [PATCH] fix: gracefully handle missing test cases between two apps --- src/libs/E2E/reactNativeLaunchingTest.ts | 1 + tests/e2e/server/index.ts | 12 +++++++++--- tests/e2e/testRunner.ts | 2 ++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/libs/E2E/reactNativeLaunchingTest.ts b/src/libs/E2E/reactNativeLaunchingTest.ts index 9d5b0be0d2e7..f23508987268 100644 --- a/src/libs/E2E/reactNativeLaunchingTest.ts +++ b/src/libs/E2E/reactNativeLaunchingTest.ts @@ -66,6 +66,7 @@ E2EClient.getTestConfig() console.error(`[E2E] Test '${config.name}' not found`); // instead of throwing, report the error to the server, which is better for DX return E2EClient.submitTestResults({ + branch: Config.E2E_BRANCH, name: config.name, error: `Test '${config.name}' not found`, isCritical: false, diff --git a/tests/e2e/server/index.ts b/tests/e2e/server/index.ts index 34a19b52d97e..51b73447bab4 100644 --- a/tests/e2e/server/index.ts +++ b/tests/e2e/server/index.ts @@ -27,6 +27,7 @@ type ServerInstance = { addTestStartedListener: AddListener; addTestResultListener: AddListener; addTestDoneListener: AddListener; + forceTestCompletion: () => void; start: () => Promise; stop: () => Promise; }; @@ -96,6 +97,12 @@ const createServerInstance = (): ServerInstance => { const [testResultListeners, addTestResultListener] = createListenerState(); const [testDoneListeners, addTestDoneListener] = createListenerState(); + const forceTestCompletion = () => { + testDoneListeners.forEach((listener) => { + listener(); + }); + }; + let activeTestConfig: TestConfig | undefined; const networkCache: Record = {}; @@ -131,9 +138,7 @@ const createServerInstance = (): ServerInstance => { } case Routes.testDone: { - testDoneListeners.forEach((listener) => { - listener(); - }); + forceTestCompletion(); return res.end('ok'); } @@ -200,6 +205,7 @@ const createServerInstance = (): ServerInstance => { addTestStartedListener, addTestResultListener, addTestDoneListener, + forceTestCompletion, start: () => new Promise((resolve) => { server.listen(PORT, resolve); diff --git a/tests/e2e/testRunner.ts b/tests/e2e/testRunner.ts index 13a57312f355..ee8cf45df191 100644 --- a/tests/e2e/testRunner.ts +++ b/tests/e2e/testRunner.ts @@ -99,6 +99,8 @@ const runTests = async (): Promise => { throw new Error(`Test '${testResult.name}' failed with error: ${testResult.error}`); } if (testResult?.error != null && !isCritical) { + // force test completion, since we don't want to have timeout error for non being execute test + server.forceTestCompletion(); Logger.warn(`Test '${testResult.name}' failed with error: ${testResult.error}`); } let result = 0;