Skip to content

Commit

Permalink
feat: ✨ add e2e tests Github Actions worflow
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmy-guzman committed Dec 7, 2023
1 parent 09b0cde commit 7bd5d2a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -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 }}
4 changes: 2 additions & 2 deletions e2e/app.spec.ts
Original file line number Diff line number Diff line change
@@ -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 }) => {
Expand Down
5 changes: 4 additions & 1 deletion playwright.config.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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,
})

0 comments on commit 7bd5d2a

Please sign in to comment.