Skip to content

Commit

Permalink
front: rethrow fatal errors in E2E tests
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
emersion committed Mar 3, 2025
1 parent 1bd3872 commit 846cf3d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion front/tests/global-teardown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
}
});
2 changes: 1 addition & 1 deletion front/tests/utils/api-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export const getInfraById = async (infraId: number): Promise<InfraWithState> =>
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 });
}
};

Expand Down
2 changes: 1 addition & 1 deletion front/tests/utils/setup-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,6 @@ export async function createDataForTests(): Promise<void> {

await setStdcmEnvironment(stdcmEnvironment);
} catch (error) {
logger.error('Error during test data setup:', error);
throw new Error('Error during test data setup', { cause: error });
}
}

0 comments on commit 846cf3d

Please sign in to comment.