Skip to content

Commit 9705119

Browse files
committed
playwright frontend tests
1 parent 23acf75 commit 9705119

5 files changed

Lines changed: 28 additions & 6 deletions

File tree

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1-
import { test, expect, describe } from "bun:test";
1+
import { test, expect } from "@playwright/test";
22

3-
describe("Frontend Smoke Test", () => {
4-
test("it works", async () => {
5-
expect(true).toBe(true);
3+
test.describe("Frontend Smoke Test", () => {
4+
test("homepage loads and shows main elements", async ({ page }) => {
5+
await page.goto("http://localhost:3000/");
6+
await expect(
7+
page.getByRole("heading", { name: "Bun Actionhero" }),
8+
).toBeVisible();
9+
await expect(
10+
page.getByRole("link", { name: "View API Endpoints" }),
11+
).toBeVisible();
612
});
713
});

frontend/bun.lockb

1.38 KB
Binary file not shown.

frontend/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
"compileNext": "bun run next build",
1313
"lint": "prettier --check .",
1414
"format": "prettier --write .",
15-
"types": "bun --cwd ../backend types && rm -rf ./types && mkdir -p ./types && cp -r ../backend/types ./types/backend"
15+
"types": "bun --cwd ../backend types && rm -rf ./types && mkdir -p ./types && cp -r ../backend/types ./types/backend",
16+
"test:e2e": "playwright test"
1617
},
1718
"dependencies": {
1819
"next": "^14.2.7",
@@ -22,6 +23,7 @@
2223
"typescript": "^5.4.3"
2324
},
2425
"devDependencies": {
26+
"@playwright/test": "^1.53.0",
2527
"@types/node": "22.7.5",
2628
"@types/react-dom": "^18.3.0",
2729
"prettier": "^3.3.3"

frontend/playwright.config.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { defineConfig } from "@playwright/test";
2+
3+
export default defineConfig({
4+
webServer: {
5+
command: "cd .. && bun dev",
6+
port: 3000,
7+
timeout: 120 * 1000, // 2 minutes
8+
reuseExistingServer: !process.env.CI,
9+
},
10+
testDir: "__tests__",
11+
use: {
12+
baseURL: "http://localhost:3000",
13+
},
14+
});

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"compile": "bun compile-backend && bun compile-frontend",
1616
"tests": "bun test-backend && bun test-frontend",
1717
"test-backend": "cd backend && bun test",
18-
"test-frontend": "cd frontend && bun test",
18+
"test-frontend": "cd frontend && bun test:e2e",
1919
"lint-backend": "cd backend && bun lint",
2020
"lint-frontend": "cd frontend && bun lint",
2121
"lint": "bun lint-backend && bun lint-frontend",

0 commit comments

Comments
 (0)