aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/e2e-tests.yml13
-rw-r--r--playwright.config.ts50
2 files changed, 21 insertions, 42 deletions
diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml
index d55e778..ced3bbd 100644
--- a/.github/workflows/e2e-tests.yml
+++ b/.github/workflows/e2e-tests.yml
@@ -1,13 +1,13 @@
name: E2E tests
-on:
- pull_request:
- push:
- branches:
- - main
+on: [deployment_status]
+
jobs:
test:
+ if: github.event.deployment_status.state == 'success'
timeout-minutes: 60
runs-on: ubuntu-latest
+ env:
+ BASE_URL: ${{ github.event.deployment_status.target_url }}
strategy:
matrix:
shard: [1/3, 2/3, 3/3]
@@ -28,9 +28,6 @@ jobs:
- name: Install dependencies
run: pnpm install
- - name: Build app
- run: pnpm build
-
- name: Restore Playwright browsers from cache
uses: actions/cache@v3
with:
diff --git a/playwright.config.ts b/playwright.config.ts
index beb9dc6..47fa0ce 100644
--- a/playwright.config.ts
+++ b/playwright.config.ts
@@ -1,10 +1,7 @@
import { defineConfig, devices } from '@playwright/test';
-/**
- * Read environment variables from file.
- * https://github.com/motdotla/dotenv
- */
-// require('dotenv').config();
+const isCI = !!process.env.CI;
+const baseUrl = process.env.BASE_URL || 'http://localhost:5050';
/**
* See https://playwright.dev/docs/test-configuration.
@@ -15,17 +12,17 @@ export default defineConfig({
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
- forbidOnly: !!process.env.CI,
+ forbidOnly: isCI,
/* Retry on CI only */
- retries: process.env.CI ? 2 : 0,
+ retries: isCI ? 2 : 0,
/* Opt out of parallel tests on CI. */
- workers: process.env.CI ? 1 : undefined,
+ workers: isCI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: 'html',
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
- baseURL: 'http://127.0.0.1:5050',
+ baseURL: baseUrl,
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
@@ -51,32 +48,17 @@ export default defineConfig({
name: 'webkit',
use: { ...devices['Desktop Safari'] },
},
-
- /* Test against mobile viewports. */
- // {
- // name: 'Mobile Chrome',
- // use: { ...devices['Pixel 5'] },
- // },
- // {
- // name: 'Mobile Safari',
- // use: { ...devices['iPhone 12'] },
- // },
-
- /* Test against branded browsers. */
- // {
- // name: 'Microsoft Edge',
- // use: { ...devices['Desktop Edge'], channel: 'msedge' },
- // },
- // {
- // name: 'Google Chrome',
- // use: { ..devices['Desktop Chrome'], channel: 'chrome' },
- // },
],
/* Run your local dev server before starting the tests */
- webServer: {
- command: 'npm run preview',
- url: 'http://127.0.0.1:5050',
- reuseExistingServer: !process.env.CI,
- },
+
+ ...(isCI
+ ? {}
+ : {
+ webServer: {
+ command: 'npm run preview',
+ url: 'http://127.0.0.1:5050',
+ reuseExistingServer: true,
+ },
+ }),
});