diff --git a/test-storybooks/portable-stories-kitchen-sink/react-vitest-3/e2e-tests/component-testing.spec.ts b/test-storybooks/portable-stories-kitchen-sink/react-vitest-3/e2e-tests/component-testing.spec.ts index f48e6112f6df..59918515927c 100644 --- a/test-storybooks/portable-stories-kitchen-sink/react-vitest-3/e2e-tests/component-testing.spec.ts +++ b/test-storybooks/portable-stories-kitchen-sink/react-vitest-3/e2e-tests/component-testing.spec.ts @@ -82,6 +82,26 @@ test.describe("component testing", () => { }); test.afterEach(async ({ page }) => { + await page.click("body"); + try { + /** Sometimes the vitest instance fails, but the error-content is only shown in a modal. + * We click the link so the modal opens and we can close it. + * Having it open shortly is enough to have it be in the playwright trace, for debugging purposes. + */ + const descriptionButton = page.locator("#testing-module-description a"); + if ( + await descriptionButton.isVisible({ timeout: 4000 }).catch(() => false) + ) { + await descriptionButton.click({ timeout: 4000, force: true }); + + await page + .getByLabel("Close modal") + .click({ timeout: 4000, force: true }); + } + } catch { + // Ignore any errors when trying to open the modal + } + await restoreAllFiles(); const expandTestingModule = page.getByLabel("Expand testing module"); diff --git a/test-storybooks/portable-stories-kitchen-sink/react/e2e-tests/component-testing.spec.ts b/test-storybooks/portable-stories-kitchen-sink/react/e2e-tests/component-testing.spec.ts index b4b5bfbe5fa2..2c9f06c4f4c6 100644 --- a/test-storybooks/portable-stories-kitchen-sink/react/e2e-tests/component-testing.spec.ts +++ b/test-storybooks/portable-stories-kitchen-sink/react/e2e-tests/component-testing.spec.ts @@ -82,6 +82,22 @@ test.describe("component testing", () => { }); test.afterEach(async ({ page }) => { + await page.click("body"); + try { + const descriptionButton = page.locator("#testing-module-description a"); + if ( + await descriptionButton.isVisible({ timeout: 4000 }).catch(() => false) + ) { + await descriptionButton.click({ timeout: 4000, force: true }); + + await page + .getByLabel("Close modal") + .click({ timeout: 4000, force: true }); + } + } catch { + // Ignore any errors when trying to open the modal + } + await restoreAllFiles(); const expandTestingModule = page.getByLabel("Expand testing module");