1
- import { defineConfig , devices } from '@playwright/test' ;
1
+ import { defineConfig , devices } from '@playwright/experimental-ct-react'
2
+ import react from '@vitejs/plugin-react'
2
3
3
4
/**
4
5
* Read environment variables from file.
5
6
* https://github.com/motdotla/dotenv
6
7
*/
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' ) } )
9
16
10
17
/**
11
18
* See https://playwright.dev/docs/test-configuration.
@@ -25,28 +32,37 @@ export default defineConfig({
25
32
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
26
33
use : {
27
34
/* 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
+ } ,
29
45
30
46
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
31
- trace : 'on-first-retry' ,
47
+ trace : 'on-first-retry'
32
48
} ,
33
49
34
50
/* Configure projects for major browsers */
35
51
projects : [
36
52
{
37
53
name : 'chromium' ,
38
- use : { ...devices [ 'Desktop Chrome' ] } ,
54
+ use : { ...devices [ 'Desktop Chrome' ] }
39
55
} ,
40
56
41
57
{
42
58
name : 'firefox' ,
43
- use : { ...devices [ 'Desktop Firefox' ] } ,
59
+ use : { ...devices [ 'Desktop Firefox' ] }
44
60
} ,
45
61
46
62
{
47
63
name : 'webkit' ,
48
- use : { ...devices [ 'Desktop Safari' ] } ,
49
- } ,
64
+ use : { ...devices [ 'Desktop Safari' ] }
65
+ }
50
66
51
67
/* Test against mobile viewports. */
52
68
// {
@@ -70,9 +86,8 @@ export default defineConfig({
70
86
] ,
71
87
72
88
/* 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