diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml new file mode 100644 index 0000000..2364599 --- /dev/null +++ b/.github/workflows/e2e.yml @@ -0,0 +1,26 @@ +name: e2e + +on: [deployment_status] + +jobs: + e2e: + if: github.event.deployment_status.state == 'success' + runs-on: ubuntu-latest + + steps: + - name: 🏗 Setup Repository + uses: actions/checkout@v3 + + - name: 📦 Install + uses: ./.github/actions/install + with: + node-version: 20 + pnpm-version: 8.10.5 + + - name: 📦 Install Playwright Deps + run: pnpm exec playwright install --with-deps + + - name: ✅ e2e + run: pnpm e2e + env: + BASE_URL: ${{ github.event.deployment_status.environment_url }} diff --git a/e2e/app.spec.ts b/e2e/app.spec.ts index 331513f..6ec52d2 100644 --- a/e2e/app.spec.ts +++ b/e2e/app.spec.ts @@ -1,14 +1,14 @@ import { expect, test } from '@playwright/test' test('has title', async ({ page }) => { - await page.goto('http://localhost:5173/') + await page.goto('/') await expect(page).toHaveTitle(/React Starter/) }) test.describe('external links', () => { test.beforeEach(async ({ page }) => { - await page.goto('http://localhost:5173/') + await page.goto('/') }) test('opened vite docs', async ({ page, context }) => { diff --git a/playwright.config.ts b/playwright.config.ts index 6b7d49a..0d8cd37 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -1,5 +1,8 @@ import { defineConfig, devices } from '@playwright/test' +const PORT = process.env.PORT ?? 5173 +const BASE_URL = process.env.BASE_URL ?? `http://localhost:${PORT}` + export default defineConfig({ forbidOnly: Boolean(process.env.CI), fullyParallel: true, @@ -22,6 +25,6 @@ export default defineConfig({ reporter: 'html', retries: process.env.CI ? 2 : 0, testDir: './e2e', - use: { trace: 'on-first-retry' }, + use: { trace: 'on-first-retry', baseURL: BASE_URL }, workers: process.env.CI ? 1 : undefined, })