Skip to content

Commit

Permalink
feat(e2e): Introduce JS exception catcher to whole test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
Vere-Grey committed Feb 3, 2025
1 parent 97621a3 commit 6cd87f6
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions packages/suite-desktop-core/e2e/support/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ type Fixtures = {
indexedDb: IndexedDbFixture;
metadataProviderMock: MetadataProviderMock;
blockbookMock: BlockbookMock;
exceptionLogger: void;
};

const test = base.extend<Fixtures>({
Expand Down Expand Up @@ -217,6 +218,24 @@ const test = base.extend<Fixtures>({
const blockbookMock = new BlockbookMock();
await use(blockbookMock);
},
exceptionLogger: [
async ({ page }, use) => {
const errors: Error[] = [];
page.on('pageerror', error => {
errors.push(error);
});

await use();

if (errors.length > 0) {
throw new Error(
`There was a JS exception during test run.
\n${errors.map(error => `${error.message}\n${error.stack}`).join('\n-----\n')}`,
);
}
},
{ auto: true },
],
});

export { test };
Expand Down

0 comments on commit 6cd87f6

Please sign in to comment.