diff --git a/src/libs/E2E/reactNativeLaunchingTest.js b/src/libs/E2E/reactNativeLaunchingTest.js index 869f5d1f1f1a..f8bb59274b49 100644 --- a/src/libs/E2E/reactNativeLaunchingTest.js +++ b/src/libs/E2E/reactNativeLaunchingTest.js @@ -6,6 +6,7 @@ */ import Performance from '../Performance'; +import * as Metrics from '../Metrics'; // start the usual app Performance.markStart('regularAppStart'); @@ -19,6 +20,11 @@ console.debug('=========================='); console.debug('==== Running e2e test ===='); console.debug('=========================='); +// Check if the performance module is available +if (!Metrics.canCapturePerformanceMetrics()) { + throw new Error('Performance module not available! Please set CAPTURE_METRICS=true in your environment file!'); +} + // import your test here, define its name and config first in e2e/config.js const tests = { [E2EConfig.TEST_NAMES.AppStartTime]: require('./tests/appStartTimeTest.e2e').default, @@ -36,20 +42,28 @@ const appReady = new Promise((resolve) => { }); }); -E2EClient.getTestConfig().then((config) => { - const test = tests[config.name]; - if (!test) { - // instead of throwing, report the error to the server, which is better for DX - return E2EClient.submitTestResults({ - name: config.name, - error: `Test '${config.name}' not found`, - }); - } - console.debug(`[E2E] Configured for test ${config.name}. Waiting for app to become ready`); - - appReady.then(() => { - console.debug('[E2E] App is ready, running test…'); - Performance.measureFailSafe('appStartedToReady', 'regularAppStart'); - test(); +E2EClient.getTestConfig() + .then((config) => { + const test = tests[config.name]; + if (!test) { + // instead of throwing, report the error to the server, which is better for DX + return E2EClient.submitTestResults({ + name: config.name, + error: `Test '${config.name}' not found`, + }); + } + + console.debug(`[E2E] Configured for test ${config.name}. Waiting for app to become ready`); + appReady + .then(() => { + console.debug('[E2E] App is ready, running test…'); + Performance.measureFailSafe('appStartedToReady', 'regularAppStart'); + test(); + }) + .catch((error) => { + console.error('[E2E] Error while waiting for app to become ready', error); + }); + }) + .catch((error) => { + console.error("[E2E] Error while running test. Couldn't get test config!", error); }); -});