From 846cf3d4a529fe4fb7b203248c09eebdde964487 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Mon, 3 Mar 2025 17:11:36 +0100 Subject: [PATCH] front: rethrow fatal errors in E2E tests The global setup function logs a message and carries on when it fails. This makes it difficult to read logs: all tests fail with non-sensical errors. Instead, rethrow the error by setting the cause option to add more context to the logs. Signed-off-by: Simon Ser --- front/tests/global-teardown.ts | 2 +- front/tests/utils/api-utils.ts | 2 +- front/tests/utils/setup-utils.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/front/tests/global-teardown.ts b/front/tests/global-teardown.ts index 64d9625f85a..df6da3abfea 100644 --- a/front/tests/global-teardown.ts +++ b/front/tests/global-teardown.ts @@ -51,6 +51,6 @@ teardown('teardown', async ({ browser }) => { logger.info('Test data teardown completed successfully.'); } catch (error) { - logger.error('Error during test data teardown:', error); + throw new Error('Error during test data teardown', { cause: error }); } }); diff --git a/front/tests/utils/api-utils.ts b/front/tests/utils/api-utils.ts index ebc578671f2..c018e6b9173 100644 --- a/front/tests/utils/api-utils.ts +++ b/front/tests/utils/api-utils.ts @@ -133,7 +133,7 @@ export const getInfraById = async (infraId: number): Promise => const response = await getApiRequest(`/api/infra/${infraId}`); return response as InfraWithState; } catch (error) { - throw new Error(`Failed to retrieve infrastructure with ID ${infraId}: ${error}`); + throw new Error(`Failed to retrieve infrastructure with ID ${infraId}`, { cause: error }); } }; diff --git a/front/tests/utils/setup-utils.ts b/front/tests/utils/setup-utils.ts index 498af47103a..92e04b76da7 100644 --- a/front/tests/utils/setup-utils.ts +++ b/front/tests/utils/setup-utils.ts @@ -250,6 +250,6 @@ export async function createDataForTests(): Promise { await setStdcmEnvironment(stdcmEnvironment); } catch (error) { - logger.error('Error during test data setup:', error); + throw new Error('Error during test data setup', { cause: error }); } }