Skip to content

Commit

Permalink
test: add E2E tests with Playwright (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
geoffrich authored Oct 31, 2022
1 parent 57bba67 commit e381aec
Show file tree
Hide file tree
Showing 10 changed files with 170 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,30 @@ jobs:
api_location: 'demo/api' # Api source code path - optional
output_location: 'build/static' # Built app content directory - optional
###### End of Repository/Build Configurations ######
outputs:
preview_url: ${{ steps.builddeploy.outputs.static_web_app_url }}
test:
needs: build_and_deploy_job
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
name: Run E2E Tests
timeout-minutes: 10
runs-on: ubuntu-latest
defaults:
run:
working-directory: demo
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v2
with:
node-version: '16.x'
- name: Install dependencies
run: npm ci
- name: Install Playwright
run: npx playwright install --with-deps
- name: Run Playwright tests
run: npm test
env:
PLAYWRIGHT_TEST_BASE_URL: ${{ needs.build_and_deploy_job.outputs.preview_url }}

close_pull_request_job:
if: github.event_name == 'pull_request' && github.event.action == 'closed'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
branches: [main]

jobs:
build:
test:
runs-on: ubuntu-latest

steps:
Expand Down
148 changes: 87 additions & 61 deletions demo/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"build": "vite build",
"preview": "vite preview",
"check": "svelte-kit sync && svelte-check --tsconfig ./jsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./jsconfig.json --watch"
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./jsconfig.json --watch",
"test": "playwright test"
},
"engines": {
"npm": ">=8.7.0 < 9",
Expand All @@ -16,6 +17,7 @@
"devDependencies": {
"@fontsource/fira-mono": "^4.5.0",
"@neoconfetti/svelte": "^1.0.0",
"@playwright/test": "^1.25.0",
"@sveltejs/adapter-auto": "next",
"@sveltejs/kit": "next",
"@types/cookie": "^0.5.1",
Expand Down
11 changes: 11 additions & 0 deletions demo/playwright.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/** @type {import('@playwright/test').PlaywrightTestConfig} */
const config = {
webServer: process.env.CI
? undefined
: {
command: 'npm run build && npm run preview',
port: 4173
}
};

export default config;
Loading

0 comments on commit e381aec

Please sign in to comment.