Skip to content

Commit 5b92494

Browse files
chore: use defineConfig (#77)
Co-authored-by: Max Schmitt <[email protected]>
1 parent 42dcdc9 commit 5b92494

File tree

7 files changed

+53
-107
lines changed

7 files changed

+53
-107
lines changed

assets/playwright-ct.config.js

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
// @ts-check
2-
const { devices } = require('{{ctPackageName}}');
2+
const { defineConfig, devices } = require('{{ctPackageName}}');
33

44
/**
55
* @see https://playwright.dev/docs/test-configuration
6-
* @type {import('{{ctPackageName}}').PlaywrightTestConfig}
76
*/
8-
const config = {
7+
module.exports = defineConfig({
98
testDir: './{{testDir}}',
109
/* The base directory, relative to the config file, for snapshot files created with toMatchSnapshot and toHaveScreenshot. */
1110
snapshotDir: './__snapshots__',
@@ -34,23 +33,15 @@ const config = {
3433
projects: [
3534
{
3635
name: 'chromium',
37-
use: {
38-
...devices['Desktop Chrome'],
39-
},
36+
use: { ...devices['Desktop Chrome'] },
4037
},
4138
{
4239
name: 'firefox',
43-
use: {
44-
...devices['Desktop Firefox'],
45-
},
40+
use: { ...devices['Desktop Firefox'] },
4641
},
4742
{
4843
name: 'webkit',
49-
use: {
50-
...devices['Desktop Safari'],
51-
},
44+
use: { ...devices['Desktop Safari'] },
5245
},
5346
],
54-
};
55-
56-
module.exports = config;
47+
});

assets/playwright-ct.config.ts

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import type { PlaywrightTestConfig } from '{{ctPackageName}}';
2-
import { devices } from '{{ctPackageName}}';
1+
import { defineConfig, devices } from '{{ctPackageName}}';
32

43
/**
54
* See https://playwright.dev/docs/test-configuration.
65
*/
7-
const config: PlaywrightTestConfig = {
6+
export default defineConfig({
87
testDir: './{{testDir}}',
98
/* The base directory, relative to the config file, for snapshot files created with toMatchSnapshot and toHaveScreenshot. */
109
snapshotDir: './__snapshots__',
@@ -33,23 +32,15 @@ const config: PlaywrightTestConfig = {
3332
projects: [
3433
{
3534
name: 'chromium',
36-
use: {
37-
...devices['Desktop Chrome'],
38-
},
35+
use: { ...devices['Desktop Chrome'] },
3936
},
4037
{
4138
name: 'firefox',
42-
use: {
43-
...devices['Desktop Firefox'],
44-
},
39+
use: { ...devices['Desktop Firefox'] },
4540
},
4641
{
4742
name: 'webkit',
48-
use: {
49-
...devices['Desktop Safari'],
50-
},
43+
use: { ...devices['Desktop Safari'] },
5144
},
5245
],
53-
};
54-
55-
export default config;
46+
});

assets/playwright.config.js

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
// @ts-check
2-
const { devices } = require('@playwright/test');
2+
const { defineConfig, devices } = require('@playwright/test');
33

44
/**
55
* Read environment variables from file.
66
* https://github.com/motdotla/dotenv
77
*/
88
// require('dotenv').config();
99

10-
1110
/**
1211
* @see https://playwright.dev/docs/test-configuration
13-
* @type {import('@playwright/test').PlaywrightTestConfig}
1412
*/
15-
const config = {
13+
module.exports = defineConfig({
1614
testDir: './{{testDir}}',
1715
/* Maximum time one test can run for. */
1816
timeout: 30 * 1000,
@@ -49,56 +47,42 @@ const config = {
4947
//--begin-chromium
5048
{
5149
name: 'chromium',
52-
use: {
53-
...devices['Desktop Chrome'],
54-
},
50+
use: { ...devices['Desktop Chrome'] },
5551
},
5652
//--end-chromium
5753

5854
//--begin-firefox
5955
{
6056
name: 'firefox',
61-
use: {
62-
...devices['Desktop Firefox'],
63-
},
57+
use: { ...devices['Desktop Firefox'] },
6458
},
6559
//--end-firefox
6660

6761
//--begin-webkit
6862
{
6963
name: 'webkit',
70-
use: {
71-
...devices['Desktop Safari'],
72-
},
64+
use: { ...devices['Desktop Safari'] },
7365
},
7466
//--end-webkit
7567

7668
/* Test against mobile viewports. */
7769
// {
7870
// name: 'Mobile Chrome',
79-
// use: {
80-
// ...devices['Pixel 5'],
81-
// },
71+
// use: { ...devices['Pixel 5'] },
8272
// },
8373
// {
8474
// name: 'Mobile Safari',
85-
// use: {
86-
// ...devices['iPhone 12'],
87-
// },
75+
// use: { ...devices['iPhone 12'] },
8876
// },
8977

9078
/* Test against branded browsers. */
9179
// {
9280
// name: 'Microsoft Edge',
93-
// use: {
94-
// channel: 'msedge',
95-
// },
81+
// use: { channel: 'msedge' },
9682
// },
9783
// {
9884
// name: 'Google Chrome',
99-
// use: {
100-
// channel: 'chrome',
101-
// },
85+
// use: { channel: 'chrome' },
10286
// },
10387
],
10488

@@ -110,6 +94,5 @@ const config = {
11094
// command: 'npm run start',
11195
// port: 3000,
11296
// },
113-
};
97+
});
11498

115-
module.exports = config;

assets/playwright.config.ts

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import type { PlaywrightTestConfig } from '@playwright/test';
2-
import { devices } from '@playwright/test';
1+
import { defineConfig, devices } from '@playwright/test';
32

43
/**
54
* Read environment variables from file.
@@ -10,7 +9,7 @@ import { devices } from '@playwright/test';
109
/**
1110
* See https://playwright.dev/docs/test-configuration.
1211
*/
13-
const config: PlaywrightTestConfig = {
12+
export default defineConfig({
1413
testDir: './{{testDir}}',
1514
/* Maximum time one test can run for. */
1615
timeout: 30 * 1000,
@@ -47,56 +46,42 @@ const config: PlaywrightTestConfig = {
4746
//--begin-chromium
4847
{
4948
name: 'chromium',
50-
use: {
51-
...devices['Desktop Chrome'],
52-
},
49+
use: { ...devices['Desktop Chrome'] },
5350
},
5451
//--end-chromium
5552

5653
//--begin-firefox
5754
{
5855
name: 'firefox',
59-
use: {
60-
...devices['Desktop Firefox'],
61-
},
56+
use: { ...devices['Desktop Firefox'] },
6257
},
6358
//--end-firefox
6459

6560
//--begin-webkit
6661
{
6762
name: 'webkit',
68-
use: {
69-
...devices['Desktop Safari'],
70-
},
63+
use: { ...devices['Desktop Safari'] },
7164
},
7265
//--end-webkit
7366

7467
/* Test against mobile viewports. */
7568
// {
7669
// name: 'Mobile Chrome',
77-
// use: {
78-
// ...devices['Pixel 5'],
79-
// },
70+
// use: { ...devices['Pixel 5'] },
8071
// },
8172
// {
8273
// name: 'Mobile Safari',
83-
// use: {
84-
// ...devices['iPhone 12'],
85-
// },
74+
// use: { ...devices['iPhone 12'] },
8675
// },
8776

8877
/* Test against branded browsers. */
8978
// {
9079
// name: 'Microsoft Edge',
91-
// use: {
92-
// channel: 'msedge',
93-
// },
80+
// use: { channel: 'msedge' },
9481
// },
9582
// {
9683
// name: 'Google Chrome',
97-
// use: {
98-
// channel: 'chrome',
99-
// },
84+
// use: { channel: 'chrome' },
10085
// },
10186
],
10287

@@ -108,6 +93,4 @@ const config: PlaywrightTestConfig = {
10893
// command: 'npm run start',
10994
// port: 3000,
11095
// },
111-
};
112-
113-
export default config;
96+
});

package-lock.json

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"prepublish": "npm run build"
2323
},
2424
"devDependencies": {
25-
"@playwright/test": "^1.27.0",
25+
"@playwright/test": "^1.30.0",
2626
"@types/node": "^16.11.11",
2727
"ansi-colors": "^4.1.1",
2828
"enquirer": "^2.3.6",

playwright.config.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,23 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
import { PlaywrightTestConfig } from '@playwright/test';
16+
import { defineConfig } from '@playwright/test';
1717
import type { TestFixtures } from './tests/baseFixtures';
1818

19-
const config: PlaywrightTestConfig<TestFixtures> = {
19+
export default defineConfig<TestFixtures>({
2020
timeout: 120 * 1000,
2121
testDir: './tests',
2222
reporter: 'list',
2323
workers: process.env.CI ? 1 : undefined,
2424
projects: [
2525
{
26-
name: 'NPM',
26+
name: 'npm',
2727
use: {
2828
packageManager: 'npm'
2929
}
3030
},
3131
{
32-
name: 'Yarn',
32+
name: 'yarn',
3333
use: {
3434
packageManager: 'yarn'
3535
}
@@ -41,6 +41,4 @@ const config: PlaywrightTestConfig<TestFixtures> = {
4141
}
4242
},
4343
]
44-
};
45-
46-
export default config;
44+
});

0 commit comments

Comments
 (0)