Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Playwright Tests
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: List repo structure
run: ls -R
#backend setup and start
- name: Install backend dependencies
working-directory: backend
run: pip install -r requirements.txt

#frontend setup and run
- name: Setup pnpm
run: npm install -g pnpm

- name: Install frontend dependencies
working-directory: frontend
run: pnpm install

#Playwright setup and run tests
- name: Install Playwright Browsers
working-directory: frontend
run: pnpm exec playwright install --with-deps

- name: Run Playwright tests
working-directory: frontend
run: pnpm exec playwright test
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: playwright-report
path: frontend/playwright-report/
retention-days: 30
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@ cd fastapi-vue-spa-boilerplate
# Backend
cd backend && source .venv/bin/activate && uvicorn app.main:app --reload

# Frontend
# Frontend
cd frontend && pnpm dev

# E2E testing
cd frontend && pnpm test:e2e

```

- Frontend: http://localhost:3000
- Backend: http://localhost:8000
- API Docs: http://localhost:8000/docs
- API Docs: http://localhost:8000/docs
7 changes: 7 additions & 0 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,10 @@ dist-ssr
*.njsproj
*.sln
*.sw?

# Playwright
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
/playwright/.auth/
16 changes: 16 additions & 0 deletions frontend/e2e/homepage.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { test, expect } from "@playwright/test";

test("should display the correct page title", async ({ page }) => {
await page.goto("/");

await expect(page).toHaveTitle("Vite + Vue + TS");
});

test("should display backend health status", async ({ page }) => {
await page.goto("/");

const healthStatus = page.getByRole("paragraph");
await expect(healthStatus).toHaveText(
'Health: {"status":"healthy","message":"FastAPI backend is running","environment":"development","version":"1.0.0"}',
);
});
4 changes: 3 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
"version": "0.0.0",
"scripts": {
"dev": "vite",
"build": "vite build"
"build": "vite build",
"test:e2e": "pnpm exec playwright test"
},
"dependencies": {
"vue": "^3.4.0"
},
"devDependencies": {
"@playwright/test": "^1.59.1",
"@types/node": "^24.3.0",
"@vitejs/plugin-vue": "^4.5.0",
"@vue/tsconfig": "^0.8.1",
Expand Down
46 changes: 46 additions & 0 deletions frontend/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { defineConfig, devices } from "@playwright/test";
import path from "path";

const absolutePathBackend = path.resolve(__dirname, "../backend");

export default defineConfig({
testDir: "./e2e",

fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 1 : undefined,
reporter: "html",
use: {
baseURL: "http://127.0.0.1:5173",
},

projects: [
{
name: "chromium",
use: { ...devices["Desktop Chrome"] },
},

{
name: "firefox",
use: { ...devices["Desktop Firefox"] },
},

{
name: "webkit",
use: { ...devices["Desktop Safari"] },
},
],

/* Run your local dev server before starting the tests*/
webServer: [
{
command: `cd ${absolutePathBackend} && uvicorn app.main:app --host 127.0.0.1 --port 8000`,
url: "http://127.0.0.1:8000",
},
{
command: "pnpm dev --host 0.0.0.0",
url: "http://127.0.0.1:5173",
},
],
});
38 changes: 38 additions & 0 deletions frontend/pnpm-lock.yaml

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

2 changes: 2 additions & 0 deletions frontend/pnpm-workspace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
allowBuilds:
esbuild: true
43 changes: 43 additions & 0 deletions pnpm-lock.yaml

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