Skip to content

Commit 5cc4615

Browse files
committed
tests: add first test
1 parent 0b4c7d5 commit 5cc4615

File tree

5 files changed

+172
-104
lines changed

5 files changed

+172
-104
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ node_modules
1111
dist
1212
dist-ssr
1313
*.local
14+
*.env
1415

1516
# Editor directories and files
1617
.vscode/*
@@ -25,4 +26,4 @@ dist-ssr
2526
/test-results/
2627
/playwright-report/
2728
/blob-report/
28-
/playwright/.cache/
29+
/playwright/.cache/

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
"zod": "^3.23.8"
2525
},
2626
"devDependencies": {
27+
"dotenv": "^16.4.5",
28+
"@playwright/experimental-ct-react": "^1.45.1",
2729
"@playwright/test": "^1.45.1",
2830
"@types/node": "^20.14.10",
2931
"@types/react": "^18.3.3",

playwright.config.ts

+30-15
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
1-
import { defineConfig, devices } from '@playwright/test';
1+
import { defineConfig, devices } from '@playwright/experimental-ct-react'
2+
import react from '@vitejs/plugin-react'
23

34
/**
45
* Read environment variables from file.
56
* https://github.com/motdotla/dotenv
67
*/
7-
// import dotenv from 'dotenv';
8-
// dotenv.config({ path: path.resolve(__dirname, '.env') });
8+
import dotenv from 'dotenv'
9+
import { fileURLToPath } from 'url'
10+
import path from 'path'
11+
12+
const __filename = fileURLToPath(import.meta.url)
13+
const __dirname = path.dirname(__filename)
14+
15+
dotenv.config({ path: path.resolve(__dirname, '.env') })
916

1017
/**
1118
* See https://playwright.dev/docs/test-configuration.
@@ -25,28 +32,37 @@ export default defineConfig({
2532
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
2633
use: {
2734
/* Base URL to use in actions like `await page.goto('/')`. */
28-
// baseURL: 'http://127.0.0.1:3000',
35+
baseURL: process.env.BASE_URL || 'http://localhost:3000',
36+
37+
ctViteConfig: {
38+
plugins: [react()],
39+
resolve: {
40+
alias: {
41+
'@': path.resolve(__dirname, './src')
42+
}
43+
}
44+
},
2945

3046
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
31-
trace: 'on-first-retry',
47+
trace: 'on-first-retry'
3248
},
3349

3450
/* Configure projects for major browsers */
3551
projects: [
3652
{
3753
name: 'chromium',
38-
use: { ...devices['Desktop Chrome'] },
54+
use: { ...devices['Desktop Chrome'] }
3955
},
4056

4157
{
4258
name: 'firefox',
43-
use: { ...devices['Desktop Firefox'] },
59+
use: { ...devices['Desktop Firefox'] }
4460
},
4561

4662
{
4763
name: 'webkit',
48-
use: { ...devices['Desktop Safari'] },
49-
},
64+
use: { ...devices['Desktop Safari'] }
65+
}
5066

5167
/* Test against mobile viewports. */
5268
// {
@@ -70,9 +86,8 @@ export default defineConfig({
7086
],
7187

7288
/* 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-
});
89+
webServer: {
90+
command: 'pnpm run dev',
91+
reuseExistingServer: !process.env.CI
92+
}
93+
})

0 commit comments

Comments
 (0)