From 5b924949f3fa7ecc4751119d68a049147e1437a9 Mon Sep 17 00:00:00 2001 From: Pavel Feldman Date: Mon, 6 Feb 2023 12:35:11 -0800 Subject: [PATCH] chore: use defineConfig (#77) Co-authored-by: Max Schmitt --- assets/playwright-ct.config.js | 21 ++++++------------- assets/playwright-ct.config.ts | 21 ++++++------------- assets/playwright.config.js | 37 +++++++++------------------------- assets/playwright.config.ts | 37 +++++++++------------------------- package-lock.json | 30 +++++++++++++-------------- package.json | 2 +- playwright.config.ts | 12 +++++------ 7 files changed, 53 insertions(+), 107 deletions(-) diff --git a/assets/playwright-ct.config.js b/assets/playwright-ct.config.js index 85ab374..eb13f62 100644 --- a/assets/playwright-ct.config.js +++ b/assets/playwright-ct.config.js @@ -1,11 +1,10 @@ // @ts-check -const { devices } = require('{{ctPackageName}}'); +const { defineConfig, devices } = require('{{ctPackageName}}'); /** * @see https://playwright.dev/docs/test-configuration - * @type {import('{{ctPackageName}}').PlaywrightTestConfig} */ -const config = { +module.exports = defineConfig({ testDir: './{{testDir}}', /* The base directory, relative to the config file, for snapshot files created with toMatchSnapshot and toHaveScreenshot. */ snapshotDir: './__snapshots__', @@ -34,23 +33,15 @@ const config = { projects: [ { name: 'chromium', - use: { - ...devices['Desktop Chrome'], - }, + use: { ...devices['Desktop Chrome'] }, }, { name: 'firefox', - use: { - ...devices['Desktop Firefox'], - }, + use: { ...devices['Desktop Firefox'] }, }, { name: 'webkit', - use: { - ...devices['Desktop Safari'], - }, + use: { ...devices['Desktop Safari'] }, }, ], -}; - -module.exports = config; +}); diff --git a/assets/playwright-ct.config.ts b/assets/playwright-ct.config.ts index 07e306f..b8429d7 100644 --- a/assets/playwright-ct.config.ts +++ b/assets/playwright-ct.config.ts @@ -1,10 +1,9 @@ -import type { PlaywrightTestConfig } from '{{ctPackageName}}'; -import { devices } from '{{ctPackageName}}'; +import { defineConfig, devices } from '{{ctPackageName}}'; /** * See https://playwright.dev/docs/test-configuration. */ -const config: PlaywrightTestConfig = { +export default defineConfig({ testDir: './{{testDir}}', /* The base directory, relative to the config file, for snapshot files created with toMatchSnapshot and toHaveScreenshot. */ snapshotDir: './__snapshots__', @@ -33,23 +32,15 @@ const config: PlaywrightTestConfig = { projects: [ { name: 'chromium', - use: { - ...devices['Desktop Chrome'], - }, + use: { ...devices['Desktop Chrome'] }, }, { name: 'firefox', - use: { - ...devices['Desktop Firefox'], - }, + use: { ...devices['Desktop Firefox'] }, }, { name: 'webkit', - use: { - ...devices['Desktop Safari'], - }, + use: { ...devices['Desktop Safari'] }, }, ], -}; - -export default config; +}); diff --git a/assets/playwright.config.js b/assets/playwright.config.js index a81b73d..1ac5fd8 100644 --- a/assets/playwright.config.js +++ b/assets/playwright.config.js @@ -1,5 +1,5 @@ // @ts-check -const { devices } = require('@playwright/test'); +const { defineConfig, devices } = require('@playwright/test'); /** * Read environment variables from file. @@ -7,12 +7,10 @@ const { devices } = require('@playwright/test'); */ // require('dotenv').config(); - /** * @see https://playwright.dev/docs/test-configuration - * @type {import('@playwright/test').PlaywrightTestConfig} */ -const config = { +module.exports = defineConfig({ testDir: './{{testDir}}', /* Maximum time one test can run for. */ timeout: 30 * 1000, @@ -49,56 +47,42 @@ const config = { //--begin-chromium { name: 'chromium', - use: { - ...devices['Desktop Chrome'], - }, + use: { ...devices['Desktop Chrome'] }, }, //--end-chromium //--begin-firefox { name: 'firefox', - use: { - ...devices['Desktop Firefox'], - }, + use: { ...devices['Desktop Firefox'] }, }, //--end-firefox //--begin-webkit { name: 'webkit', - use: { - ...devices['Desktop Safari'], - }, + use: { ...devices['Desktop Safari'] }, }, //--end-webkit /* Test against mobile viewports. */ // { // name: 'Mobile Chrome', - // use: { - // ...devices['Pixel 5'], - // }, + // use: { ...devices['Pixel 5'] }, // }, // { // name: 'Mobile Safari', - // use: { - // ...devices['iPhone 12'], - // }, + // use: { ...devices['iPhone 12'] }, // }, /* Test against branded browsers. */ // { // name: 'Microsoft Edge', - // use: { - // channel: 'msedge', - // }, + // use: { channel: 'msedge' }, // }, // { // name: 'Google Chrome', - // use: { - // channel: 'chrome', - // }, + // use: { channel: 'chrome' }, // }, ], @@ -110,6 +94,5 @@ const config = { // command: 'npm run start', // port: 3000, // }, -}; +}); -module.exports = config; diff --git a/assets/playwright.config.ts b/assets/playwright.config.ts index 54151fc..222e08a 100644 --- a/assets/playwright.config.ts +++ b/assets/playwright.config.ts @@ -1,5 +1,4 @@ -import type { PlaywrightTestConfig } from '@playwright/test'; -import { devices } from '@playwright/test'; +import { defineConfig, devices } from '@playwright/test'; /** * Read environment variables from file. @@ -10,7 +9,7 @@ import { devices } from '@playwright/test'; /** * See https://playwright.dev/docs/test-configuration. */ -const config: PlaywrightTestConfig = { +export default defineConfig({ testDir: './{{testDir}}', /* Maximum time one test can run for. */ timeout: 30 * 1000, @@ -47,56 +46,42 @@ const config: PlaywrightTestConfig = { //--begin-chromium { name: 'chromium', - use: { - ...devices['Desktop Chrome'], - }, + use: { ...devices['Desktop Chrome'] }, }, //--end-chromium //--begin-firefox { name: 'firefox', - use: { - ...devices['Desktop Firefox'], - }, + use: { ...devices['Desktop Firefox'] }, }, //--end-firefox //--begin-webkit { name: 'webkit', - use: { - ...devices['Desktop Safari'], - }, + use: { ...devices['Desktop Safari'] }, }, //--end-webkit /* Test against mobile viewports. */ // { // name: 'Mobile Chrome', - // use: { - // ...devices['Pixel 5'], - // }, + // use: { ...devices['Pixel 5'] }, // }, // { // name: 'Mobile Safari', - // use: { - // ...devices['iPhone 12'], - // }, + // use: { ...devices['iPhone 12'] }, // }, /* Test against branded browsers. */ // { // name: 'Microsoft Edge', - // use: { - // channel: 'msedge', - // }, + // use: { channel: 'msedge' }, // }, // { // name: 'Google Chrome', - // use: { - // channel: 'chrome', - // }, + // use: { channel: 'chrome' }, // }, ], @@ -108,6 +93,4 @@ const config: PlaywrightTestConfig = { // command: 'npm run start', // port: 3000, // }, -}; - -export default config; +}); diff --git a/package-lock.json b/package-lock.json index 11a0664..95da6f8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ "create-playwright": "index.js" }, "devDependencies": { - "@playwright/test": "^1.27.0", + "@playwright/test": "^1.30.0", "@types/node": "^16.11.11", "ansi-colors": "^4.1.1", "enquirer": "^2.3.6", @@ -24,13 +24,13 @@ } }, "node_modules/@playwright/test": { - "version": "1.27.0", - "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.27.0.tgz", - "integrity": "sha512-L4BswoJvGkFsEHhEgzVNHBnkFB1FbnBQn3QmvTl7+AouoJQ4a8tLwZKvytdovCsNi7B5cXuRo58yGvfM5PnExw==", + "version": "1.30.0", + "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.30.0.tgz", + "integrity": "sha512-SVxkQw1xvn/Wk/EvBnqWIq6NLo1AppwbYOjNLmyU0R1RoQ3rLEBtmjTnElcnz8VEtn11fptj1ECxK0tgURhajw==", "dev": true, "dependencies": { "@types/node": "*", - "playwright-core": "1.27.0" + "playwright-core": "1.30.0" }, "bin": { "playwright": "cli.js" @@ -422,9 +422,9 @@ } }, "node_modules/playwright-core": { - "version": "1.27.0", - "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.27.0.tgz", - "integrity": "sha512-VBKaaFUVKDo3akW+o4DwbK1ZyXh46tcSwQKPK3lruh8IJd5feu55XVZx4vOkbb2uqrNdIF51sgsadYT533SdpA==", + "version": "1.30.0", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.30.0.tgz", + "integrity": "sha512-7AnRmTCf+GVYhHbLJsGUtskWTE33SwMZkybJ0v6rqR1boxq2x36U7p1vDRV7HO2IwTZgmycracLxPEJI49wu4g==", "dev": true, "bin": { "playwright": "cli.js" @@ -449,13 +449,13 @@ }, "dependencies": { "@playwright/test": { - "version": "1.27.0", - "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.27.0.tgz", - "integrity": "sha512-L4BswoJvGkFsEHhEgzVNHBnkFB1FbnBQn3QmvTl7+AouoJQ4a8tLwZKvytdovCsNi7B5cXuRo58yGvfM5PnExw==", + "version": "1.30.0", + "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.30.0.tgz", + "integrity": "sha512-SVxkQw1xvn/Wk/EvBnqWIq6NLo1AppwbYOjNLmyU0R1RoQ3rLEBtmjTnElcnz8VEtn11fptj1ECxK0tgURhajw==", "dev": true, "requires": { "@types/node": "*", - "playwright-core": "1.27.0" + "playwright-core": "1.30.0" } }, "@types/node": { @@ -648,9 +648,9 @@ "optional": true }, "playwright-core": { - "version": "1.27.0", - "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.27.0.tgz", - "integrity": "sha512-VBKaaFUVKDo3akW+o4DwbK1ZyXh46tcSwQKPK3lruh8IJd5feu55XVZx4vOkbb2uqrNdIF51sgsadYT533SdpA==", + "version": "1.30.0", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.30.0.tgz", + "integrity": "sha512-7AnRmTCf+GVYhHbLJsGUtskWTE33SwMZkybJ0v6rqR1boxq2x36U7p1vDRV7HO2IwTZgmycracLxPEJI49wu4g==", "dev": true }, "typescript": { diff --git a/package.json b/package.json index c6ff9e0..a5769f8 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "prepublish": "npm run build" }, "devDependencies": { - "@playwright/test": "^1.27.0", + "@playwright/test": "^1.30.0", "@types/node": "^16.11.11", "ansi-colors": "^4.1.1", "enquirer": "^2.3.6", diff --git a/playwright.config.ts b/playwright.config.ts index 58c0d45..cf87857 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -13,23 +13,23 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { PlaywrightTestConfig } from '@playwright/test'; +import { defineConfig } from '@playwright/test'; import type { TestFixtures } from './tests/baseFixtures'; -const config: PlaywrightTestConfig = { +export default defineConfig({ timeout: 120 * 1000, testDir: './tests', reporter: 'list', workers: process.env.CI ? 1 : undefined, projects: [ { - name: 'NPM', + name: 'npm', use: { packageManager: 'npm' } }, { - name: 'Yarn', + name: 'yarn', use: { packageManager: 'yarn' } @@ -41,6 +41,4 @@ const config: PlaywrightTestConfig = { } }, ] -}; - -export default config; \ No newline at end of file +});