Add playwright tests with github actions

This commit is contained in:
jheaps
2025-09-24 13:48:20 -06:00
parent 7d4aff5db2
commit b425c4d5d6
14 changed files with 868 additions and 5 deletions
+73
View File
@@ -0,0 +1,73 @@
name: Playwright Tests
on:
pull_request:
branches: [ master, main ]
push:
branches: [ master, main ]
jobs:
playwright-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build solution
run: dotnet build --no-restore
- name: Install Playwright browsers
run: |
cd JoshHeaps.Net.UiTests
dotnet build
pwsh bin/Debug/net8.0/playwright.ps1 install --with-deps
- name: Start server in background
run: |
cd JoshHeaps.Net
dotnet run --urls "https://localhost:7118" &
echo $! > server.pid
# Wait for server to start
timeout 60 bash -c 'until curl -k https://localhost:7118/health 2>/dev/null; do sleep 1; done' || echo "Server may not have health endpoint, continuing..."
sleep 5
- name: Run Playwright tests
run: |
cd JoshHeaps.Net.UiTests
dotnet test --logger "trx;LogFileName=test-results.trx" --logger "console;verbosity=detailed"
env:
HEADED: false # Force headless mode in CI
- name: Stop server
if: always()
run: |
if [ -f JoshHeaps.Net/server.pid ]; then
kill $(cat JoshHeaps.Net/server.pid) || true
fi
pkill -f "dotnet run" || true
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: playwright-test-results
path: |
JoshHeaps.Net.UiTests/TestResults/
JoshHeaps.Net.UiTests/test-results/
retention-days: 7
- name: Upload Playwright videos
if: always()
uses: actions/upload-artifact@v4
with:
name: playwright-videos
path: JoshHeaps.Net.UiTests/test-results/videos/
retention-days: 7