Skip to content

Commit b4056be

Browse files
committed
feat: add Playwright testing configuration and update scripts
1 parent 1d7a39b commit b4056be

File tree

7 files changed

+148
-18
lines changed

7 files changed

+148
-18
lines changed

apps/client/.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,9 @@ dist-ssr
2323
*.sln
2424
*.sw?
2525

26-
.env
26+
.env
27+
28+
/test-results/
29+
/playwright-report/
30+
/blob-report/
31+
/playwright/.cache/

apps/client/package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
"build": "tsc -b && vite build",
99
"lint": "eslint . --fix",
1010
"format": "prettier --write .",
11-
"preview": "vite preview"
11+
"preview": "vite preview",
12+
"test": "pnpm exec playwright test --workers=1",
13+
"test-ui": "pnpm exec playwright test --ui",
14+
"test-debug": "pnpm exec playwright test --debug"
1215
},
1316
"dependencies": {
1417
"@tanstack/react-query": "^5.59.19",
@@ -28,10 +31,12 @@
2831
},
2932
"devDependencies": {
3033
"@eslint/js": "^9.11.1",
34+
"@playwright/test": "^1.49.0",
3135
"@tailwindcss/typography": "^0.5.15",
3236
"@tanstack/eslint-plugin-query": "^5.59.7",
3337
"@tanstack/router-devtools": "^1.78.3",
3438
"@tanstack/router-plugin": "^1.78.3",
39+
"@types/node": "^20.3.1",
3540
"@types/react": "^18.3.10",
3641
"@types/react-dom": "^18.3.0",
3742
"@typescript-eslint/eslint-plugin": "^7.18.0",

apps/client/playwright.config.ts

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import { defineConfig, devices } from '@playwright/test';
2+
3+
/**
4+
* Read environment variables from file.
5+
* https://github.com/motdotla/dotenv
6+
*/
7+
// import dotenv from 'dotenv';
8+
// import path from 'path';
9+
// dotenv.config({ path: path.resolve(__dirname, '.env') });
10+
11+
/**
12+
* See https://playwright.dev/docs/test-configuration.
13+
*/
14+
export default defineConfig({
15+
testDir: './tests',
16+
/* Run tests in files in parallel */
17+
fullyParallel: true,
18+
/* Fail the build on CI if you accidentally left test.only in the source code. */
19+
forbidOnly: !!process.env.CI,
20+
/* Retry on CI only */
21+
retries: process.env.CI ? 2 : 0,
22+
/* Opt out of parallel tests on CI. */
23+
workers: process.env.CI ? 1 : 1,
24+
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
25+
reporter: process.env.CI ? 'html' : 'line',
26+
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
27+
webServer: {
28+
command: 'pnpm run dev',
29+
url: 'http://localhost:5173',
30+
reuseExistingServer: !process.env.CI,
31+
stdout: 'ignore',
32+
stderr: 'pipe',
33+
},
34+
use: {
35+
/* Base URL to use in actions like `await page.goto('/')`. */
36+
baseURL: 'http://127.0.0.1:5173',
37+
38+
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
39+
trace: 'on-first-retry',
40+
},
41+
42+
/* Configure projects for major browsers */
43+
projects: [
44+
{
45+
name: 'chromium',
46+
use: { ...devices['Desktop Chrome'] },
47+
},
48+
49+
/* Test against mobile viewports. */
50+
// {
51+
// name: 'Mobile Chrome',
52+
// use: { ...devices['Pixel 5'] },
53+
// },
54+
// {
55+
// name: 'Mobile Safari',
56+
// use: { ...devices['iPhone 12'] },
57+
// },
58+
59+
/* Test against branded browsers. */
60+
// {
61+
// name: 'Microsoft Edge',
62+
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
63+
// },
64+
// {
65+
// name: 'Google Chrome',
66+
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
67+
// },
68+
],
69+
70+
/* Run your local dev server before starting the tests */
71+
// webServer: {
72+
// command: 'npm run start',
73+
// url: 'http://127.0.0.1:3000',
74+
// reuseExistingServer: !process.env.CI,
75+
// },
76+
});

apps/client/tsconfig.app.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@
2727
"@/*": ["./src/*"]
2828
}
2929
},
30-
"include": ["src"]
30+
"include": ["src", "tests", "playwright.config.ts"]
3131
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "0.0.0",
44
"description": "질문과 답변을 넘어, 함께 만드는 인사이트, ‘Ask-It’",
55
"scripts": {
6-
"test": "echo \"Error: no test specified\" && exit 1"
6+
"test": "turbo run test --filter='./apps/client/'"
77
},
88
"repository": {
99
"type": "git",

pnpm-lock.yaml

Lines changed: 54 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

turbo.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
"format": {
88
"dependsOn": [],
99
"outputs": []
10+
},
11+
"test": {
12+
"dependsOn": [],
13+
"outputs": []
1014
}
1115
}
1216
}

0 commit comments

Comments
 (0)