Skip to content

Commit 4b63945

Browse files
committed
introduce playwright
1 parent 82865b5 commit 4b63945

5 files changed

+172
-4
lines changed

.gitignore

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
node_modules/
22
coverage/
3-
.env
3+
.env
4+
/test-results/
5+
/playwright-report/
6+
/blob-report/
7+
/playwright/.cache/

e2e/index.spec.ts

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { test, expect } from '@playwright/test';
2+
3+
test('has title', async ({ page }) => {
4+
await page.goto('http://localhost:8000/');
5+
await expect(page).toHaveTitle('Open Source Test Case Management System');
6+
});

package-lock.json

+78-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,13 @@
55
"scripts": {
66
"format": "prettier --write frontend/**/*.{js,ts,jsx,tsx,json} backend/**/*.{js,ts,json}",
77
"test": "vitest",
8-
"coverage": "vitest run --coverage"
8+
"coverage": "vitest run --coverage",
9+
"e2e": "playwright test",
10+
"report": "playwright show-report"
911
},
1012
"devDependencies": {
13+
"@playwright/test": "^1.45.1",
14+
"@types/node": "^20.14.10",
1115
"@vitest/coverage-v8": "^1.6.0",
1216
"prettier": "^3.2.5",
1317
"vitest": "^1.6.0"

playwright.config.ts

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

0 commit comments

Comments
 (0)