1
1
import { devices , type PlaywrightTestConfig } from '@playwright/test' ;
2
- /**
3
- * Read environment variables from file.
4
- * https://github.com/motdotla/dotenv
5
- */
6
- // require('dotenv').config();
7
2
8
3
/**
9
4
* See https://playwright.dev/docs/test-configuration.
10
5
*/
11
6
const config : PlaywrightTestConfig = {
12
- testDir : './playwright /e2e' ,
7
+ testDir : './projects/ng-kit-demo /e2e' ,
13
8
/* Maximum time one test can run for. */
14
9
timeout : 30000 ,
15
10
expect : {
16
11
/**
17
12
* Maximum time expect() should wait for the condition to be met.
18
13
* For example in `await expect(locator).toHaveText();`
19
14
*/
20
- timeout : 30000 ,
15
+ timeout : 20000 ,
21
16
} ,
22
17
/* Run tests in files in parallel */
23
18
fullyParallel : true ,
24
19
/* Fail the build on CI if you accidentally left test.only in the source code. */
25
20
forbidOnly : ! ! process . env [ 'CI' ] ,
26
- /* Retry on CI only */
27
- retries : 2 ,
21
+ /* Retry on CI twice */
22
+ retries : process . env [ 'CI' ] ? 1 : 0 ,
28
23
/* Opt out of parallel tests on CI. */
29
- workers : process . env [ 'CI' ] ? 2 : 4 ,
24
+ workers : process . env [ 'CI' ] ? 3 : 4 ,
30
25
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
31
- reporter : process . env [ 'CI' ] ? 'dot' : 'list' ,
26
+ reporter : 'list' ,
32
27
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
33
28
use : {
34
- /* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */
35
- actionTimeout : 0 ,
36
29
/* Base URL to use in actions like `await page.goto('/')`. */
37
- //baseURL: process.env.CI ? process.env.URL : 'http://localhost:4200',
38
30
baseURL : process . env [ 'URL' ] ,
31
+
32
+ /* set data-cy as test attribute */
33
+ testIdAttribute : 'data-cy' ,
34
+
35
+ /* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */
36
+ actionTimeout : 0 ,
37
+
39
38
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
40
39
trace : 'on-first-retry' ,
41
40
screenshot : 'off' ,
@@ -44,62 +43,37 @@ const config: PlaywrightTestConfig = {
44
43
45
44
/* Configure projects for major browsers */
46
45
projects : [
46
+ { name : 'setup' , testMatch : / .* \. s e t u p \. t s / } ,
47
47
{
48
48
name : 'chromium' ,
49
-
50
- /* Project-specific settings. */
51
49
use : {
52
50
...devices [ 'Desktop Chrome' ] ,
51
+ storageState : 'playwright/.auth/read-only-user.json' ,
53
52
} ,
53
+ dependencies : [ 'setup' ] ,
54
+ } ,
55
+ {
56
+ name : 'firefox' ,
57
+ use : {
58
+ ...devices [ 'Desktop Firefox' ] ,
59
+ storageState : 'playwright/.auth/read-only-user.json' ,
60
+ } ,
61
+ dependencies : [ 'setup' ] ,
62
+ } ,
63
+ {
64
+ name : 'webkit' ,
65
+ use : {
66
+ ...devices [ 'Desktop Safari' ] ,
67
+ storageState : 'playwright/.auth/read-only-user.json' ,
68
+ } ,
69
+ dependencies : [ 'setup' ] ,
54
70
} ,
55
- /* Test against branded browsers. */
56
- // {
57
- // name: 'Microsoft Edge',
58
- // use: {
59
- // channel: 'msedge',
60
- // },
61
- // },
62
- // {
63
- // name: 'Google Chrome',
64
- // use: {
65
- // channel: 'chrome',
66
- // },
67
- // },
68
- // {
69
- // name: 'firefox',
70
- // use: {
71
- // ...devices['Desktop Firefox'],
72
- // },
73
- // },
74
- // {
75
- // name: 'webkit',
76
- // use: {
77
- // ...devices['Desktop Safari'],
78
- // },
79
- // },
80
- /* Test against mobile viewports. */
81
- // {
82
- // name: 'Mobile Chrome',
83
- // use: {
84
- // ...devices['Pixel 5'],
85
- // },
86
- // },
87
- // {
88
- // name: 'Mobile Safari',
89
- // use: {
90
- // ...devices['iPhone 12'],
91
- // },
92
- // },
93
71
] ,
94
72
95
- /* Folder for test artifacts such as screenshots, videos, traces, etc. */
96
- // outputDir: 'test-results/',
97
-
98
73
/* Run your local dev server before starting the tests */
99
- // webServer: {
100
- // command: 'npm run start',
101
- // port: 4200,
102
- // },
74
+ webServer : {
75
+ command : 'pnpm start' ,
76
+ } ,
103
77
} ;
104
78
105
79
export default config ;
0 commit comments