diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..67b980b --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,39 @@ +name: Run tests + +on: + # push: + # branches: + # - main + pull_request: + branches: + - main + +jobs: + unit_test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install pnpm + uses: pnpm/action-setup@v3 + with: + version: 8 + + - name: Install Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: pnpm + + - name: Install dependencies + run: pnpm install + + - name: Run unit tests + run: pnpm test:unit + + - name: Install playwright browsers + run: pnpm exec playwright install --with-deps + + - name: Run integration tests + run: pnpm test:integration diff --git a/playwright.config.ts b/playwright.config.ts index 1c5d7a1..3cf8326 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -2,7 +2,7 @@ import type { PlaywrightTestConfig } from '@playwright/test'; const config: PlaywrightTestConfig = { webServer: { - command: 'npm run build && npm run preview', + command: 'pnpm run build && pnpm run preview', port: 4173 }, testDir: 'tests', diff --git a/tests/test.ts b/tests/test.ts index 5816be4..47c3c06 100644 --- a/tests/test.ts +++ b/tests/test.ts @@ -2,5 +2,5 @@ import { expect, test } from '@playwright/test'; test('index page has expected h1', async ({ page }) => { await page.goto('/'); - await expect(page.getByRole('heading', { name: 'Welcome to SvelteKit' })).toBeVisible(); + await expect(page.getByRole('heading', { name: 'G\'schäft\'lhaberer' })).toBeVisible(); });