From d10a0d65b0a9f5fc52f6fe03ce1657aec800b1a5 Mon Sep 17 00:00:00 2001 From: pdamianik <39028343+pdamianik@users.noreply.github.com> Date: Thu, 29 Feb 2024 23:13:08 +0100 Subject: [PATCH] Add PR tests & checks Signed-off-by: pdamianik <39028343+pdamianik@users.noreply.github.com> --- .github/workflows/test.yml | 60 ++++++++++++++++++++++++++++++++++++++ playwright.config.ts | 2 +- tests/test.ts | 2 +- 3 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..37ab1d1 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,60 @@ +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 + + integration_test: + runs-on: ubuntu-latest + needs: unit_test + 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: 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(); });