diff --git a/packages/consent/consent-tools-integration-tests/README.md b/packages/consent/consent-tools-integration-tests/README.md index ad5181ac2..26e682bea 100644 --- a/packages/consent/consent-tools-integration-tests/README.md +++ b/packages/consent/consent-tools-integration-tests/README.md @@ -22,7 +22,7 @@ yarn . test:int ### Debugging Tips: - Webdriver.io has the handy `browser.debug()` command. -- You can serve the static pages by themselves (without webdriver.io) with the following: +- You can serve the static pages by themselves (without Playwright) with the following: ``` yarn webpack -w & npx live-server . diff --git a/packages/consent/consent-tools-integration-tests/package.json b/packages/consent/consent-tools-integration-tests/package.json index 11f5bf287..69e91a2e1 100644 --- a/packages/consent/consent-tools-integration-tests/package.json +++ b/packages/consent/consent-tools-integration-tests/package.json @@ -3,33 +3,28 @@ "private": true, "scripts": { ".": "yarn run -T turbo run --filter=@internal/consent-tools-integration-tests...", - "test:int": "yarn wdio:local", + "test:int": "playwright test", + "test:int-debug": "playwright test --debug", "build": "webpack", "watch": "yarn build --watch", - "wdio:local": "wdio wdio.conf.local.ts", "lint": "yarn concurrently 'yarn:eslint .' 'yarn:tsc --noEmit'", "eslint": "yarn run -T eslint", "tsc": "tsc", - "concurrently": "yarn run -T concurrently --raw" + "concurrently": "yarn run -T concurrently --raw", + "serve": "http-server --port 5432" }, "installConfig": { "hoistingLimits": "workspaces" }, "devDependencies": { "@internal/test-helpers": "workspace:^", + "@playwright/test": "^1.28.1", "@segment/analytics-consent-tools": "workspace:^", "@segment/analytics-consent-wrapper-onetrust": "workspace:^", "@segment/analytics-next": "workspace:^", - "@wdio/cli": "^8.10.6", - "@wdio/devtools-service": "^8.10.6", - "@wdio/local-runner": "^8.10.6", - "@wdio/mocha-framework": "^8.10.6", - "@wdio/spec-reporter": "^8.10.6", - "@wdio/static-server-service": "^8.10.6", - "@wdio/types": "8", "expect": "^29.4.1", "globby": "^11.0.2", - "wdio-intercept-service": "^4.4.0", + "http-server": "14.1.1", "webpack": "^5.94.0", "webpack-cli": "^4.8.0" } diff --git a/packages/consent/consent-tools-integration-tests/playwright.config.ts b/packages/consent/consent-tools-integration-tests/playwright.config.ts new file mode 100644 index 000000000..39b8c9182 --- /dev/null +++ b/packages/consent/consent-tools-integration-tests/playwright.config.ts @@ -0,0 +1,56 @@ +import type { PlaywrightTestConfig } from '@playwright/test' +import { devices } from '@playwright/test' +import path from 'path' + +/** + * See https://playwright.dev/docs/test-configuration. + */ +const config: PlaywrightTestConfig = { + webServer: { + command: 'yarn serve', + url: 'http://127.0.0.1:5432', + reuseExistingServer: !process.env.CI, + }, + testDir: './src/tests', + globalSetup: path.resolve(__dirname, 'playwright.global-setup.ts'), + /* Maximum time one test can run for. */ + timeout: 30 * 1000, + expect: { + /** + * Maximum time expect() should wait for the condition to be met. + * For example in `await expect(locator).toHaveText();` + */ + timeout: 5000, + }, + /* Run tests in files in parallel */ + fullyParallel: true, + /* Fail the build on CI if you accidentally left test.only in the source code. */ + forbidOnly: !!process.env.CI, + /* Retry on CI only */ + retries: process.env.CI ? 2 : 0, + /* Opt out of parallel tests on CI. */ + workers: process.env.CI ? 1 : undefined, + /* Reporter to use. See https://playwright.dev/docs/test-reporters */ + reporter: [['html', { open: 'never' }]], + /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ + use: { + /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ + baseURL: `http://127.0.0.1:5432`, + trace: 'on', + launchOptions: { + args: ['--enable-precise-memory-info', '--js-flags=--expose-gc'], + }, + }, + + /* Configure projects for major browsers */ + projects: [ + { + name: 'chromium', + use: { + ...devices['Desktop Chrome'], + }, + }, + ], +} + +export default config diff --git a/packages/consent/consent-tools-integration-tests/playwright.global-setup.ts b/packages/consent/consent-tools-integration-tests/playwright.global-setup.ts new file mode 100644 index 000000000..6a3fec2b1 --- /dev/null +++ b/packages/consent/consent-tools-integration-tests/playwright.global-setup.ts @@ -0,0 +1,8 @@ +import type { FullConfig } from '@playwright/test' +import { execSync } from 'child_process' + +export default function globalSetup(_cfg: FullConfig) { + console.log('Executing global setup...') + execSync('yarn build', { stdio: 'inherit' }) + console.log('Finished global setup.') +} diff --git a/packages/consent/consent-tools-integration-tests/public/onetrust.html b/packages/consent/consent-tools-integration-tests/public/consent-tools-onetrust.html similarity index 91% rename from packages/consent/consent-tools-integration-tests/public/onetrust.html rename to packages/consent/consent-tools-integration-tests/public/consent-tools-onetrust.html index 11065d04e..9b6f45200 100644 --- a/packages/consent/consent-tools-integration-tests/public/onetrust.html +++ b/packages/consent/consent-tools-integration-tests/public/consent-tools-onetrust.html @@ -5,9 +5,9 @@ - - - --> + +
@@ -76,4 +76,4 @@This page can used as playground or run by webdriver.io
-