From 54bcb322919a660225ec1a7e3468928ba66dd558 Mon Sep 17 00:00:00 2001 From: Emanuele Stoppa Date: Tue, 14 May 2024 10:31:32 +0100 Subject: [PATCH] test: add firefox to the list of browsers to test --- package.json | 4 +- packages/astro/package.json | 4 +- packages/astro/playwright.firefox.config.js | 43 +++++++++++++++++++++ 3 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 packages/astro/playwright.firefox.config.js diff --git a/package.json b/package.json index 1105350f54af..75fbad30ddac 100644 --- a/package.json +++ b/package.json @@ -30,8 +30,8 @@ "test:smoke:docs": "turbo run build --filter=docs", "test:check-examples": "node ./scripts/smoke/check.js", "test:vite-ci": "turbo run test --filter=astro", - "test:e2e": "cd packages/astro && pnpm playwright install chromium && pnpm run test:e2e", - "test:e2e:match": "cd packages/astro && pnpm playwright install chromium && pnpm run test:e2e:match", + "test:e2e": "cd packages/astro && pnpm playwright install chromium firefox && pnpm run test:e2e", + "test:e2e:match": "cd packages/astro && pnpm playwright install chromium firefox && pnpm run test:e2e:match", "test:e2e:hosts": "turbo run test:hosted", "benchmark": "astro-benchmark", "lint": "eslint . --report-unused-disable-directives", diff --git a/packages/astro/package.json b/packages/astro/package.json index d12048ed66cf..1e4187f3ed3c 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -112,8 +112,10 @@ "postbuild": "astro-scripts copy \"src/**/*.astro\" && astro-scripts copy \"src/**/*.wasm\"", "test": "pnpm run test:node", "test:match": "pnpm run test:node --match", - "test:e2e": "playwright test", + "test:e2e": "pnpm test:e2e:chrome && pnpm test:e2e:firefox", "test:e2e:match": "playwright test -g", + "test:e2e:chrome": "playwright test", + "test:e2e:firefox": "playwright test --config playwright.firefox.config.js", "test:node": "astro-scripts test \"test/**/*.test.js\"" }, "dependencies": { diff --git a/packages/astro/playwright.firefox.config.js b/packages/astro/playwright.firefox.config.js new file mode 100644 index 000000000000..1934a68ed1eb --- /dev/null +++ b/packages/astro/playwright.firefox.config.js @@ -0,0 +1,43 @@ +// NOTE: Sometimes, tests fail with `TypeError: process.stdout.clearLine is not a function` +// for some reason. This comes from Vite, and is conditionally called based on `isTTY`. +// We set it to false here to skip this odd behavior. +process.stdout.isTTY = false; + +const config = { + // TODO: add more tests like view transitions and audits, and fix them. Some of them are failing. + testMatch: ['e2e/css.test.js'], + /* Maximum time one test can run for. */ + timeout: 40 * 1000, + expect: { + /** + * Maximum time expect() should wait for the condition to be met. + * For example in `await expect(locator).toHaveText();` + */ + timeout: 4 * 1000, + }, + /* Fail the build on CI if you accidentally left test in the source code. */ + forbidOnly: !!process.env.CI, + /* Retry on CI only */ + retries: process.env.CI ? 3 : 0, + /* Opt out of parallel tests on CI. */ + workers: 1, + /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ + use: { + /* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */ + actionTimeout: 0, + /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ + trace: 'on-first-retry', + }, + projects: [ + { + name: 'Firefox Stable', + use: { + browserName: 'firefox', + channel: 'firefox', + args: ['--use-gl=egl'], + }, + }, + ], +}; + +export default config;