From 90b5567390f1a6520783c370792918bf5c928a36 Mon Sep 17 00:00:00 2001 From: Anssi Juvonen Date: Fri, 13 Dec 2024 19:37:58 +0200 Subject: [PATCH] Return all tests to the run --- e2e/log.spec.ts | 7 +++++-- e2e/stats.spec.ts | 11 ++++++++--- playwright.config.ts | 2 +- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/e2e/log.spec.ts b/e2e/log.spec.ts index 5150095..e3caa34 100644 --- a/e2e/log.spec.ts +++ b/e2e/log.spec.ts @@ -2,7 +2,7 @@ import {test, expect} from '@playwright/test'; // See here how to get started: // https://playwright.dev/docs/intro -test.only('logs veggies', async ({page}) => { +test('logs veggies', async ({page}) => { await page.goto('/'); await page.getByTestId('home-start-button').click(); await page.getByTestId('veggie-search-button').click(); @@ -20,8 +20,11 @@ test.only('logs veggies', async ({page}) => { const elements = page.getByTestId('toast-message'); while ((await elements.count()) > 0) { try { + // eslint-disable-next-line playwright/no-force-option await elements.first().click({force: true}); - } catch (e) {} + } catch (e) { + console.error(e); + } } await expect(page.getByTestId('toast-message')).toBeHidden(); diff --git a/e2e/stats.spec.ts b/e2e/stats.spec.ts index 02817a3..53620d5 100644 --- a/e2e/stats.spec.ts +++ b/e2e/stats.spec.ts @@ -7,9 +7,14 @@ test("shows current week's veggies", async ({page}) => { await page.getByText(/^apple$/).click(); await page.getByText('Apricot').click(); await page.getByText('Avocado').click(); - const elements = await page.getByTestId('toast-message').all(); - for (const element of elements) { - await element.click(); + const elements = page.getByTestId('toast-message'); + while ((await elements.count()) > 0) { + try { + // eslint-disable-next-line playwright/no-force-option + await elements.first().click({force: true}); + } catch (e) { + console.error(e); + } } await page.getByTestId('navbar-link-stats').click(); await expect(page.getByTestId('tag-apple')).toBeVisible(); diff --git a/playwright.config.ts b/playwright.config.ts index a9aa6b4..de9be07 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -22,7 +22,7 @@ export default defineConfig({ timeout: 3000, }, /* Fail the build on CI if you accidentally left test.only in the source code. */ - forbidOnly: false, + forbidOnly: !!process.env.CI, /* Retry on CI only */ retries: process.env.CI ? 2 : 0, /* Opt out of parallel tests on CI. */