Skip to content

Commit

Permalink
Add PR tests & checks
Browse files Browse the repository at this point in the history
Signed-off-by: pdamianik <[email protected]>
  • Loading branch information
pdamianik committed Feb 29, 2024
1 parent 286677e commit 3e44abe
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 2 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
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: Install playwright browsers
run: pnpm exec playwright install --with-deps

- 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
2 changes: 1 addition & 1 deletion playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion tests/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});

0 comments on commit 3e44abe

Please sign in to comment.