Skip to content

Commit 5a31945

Browse files
Updated the code after Seth's feedback on the PR
1 parent 64136f7 commit 5a31945

File tree

4 files changed

+55
-14
lines changed

4 files changed

+55
-14
lines changed

packages/consent/consent-tools-integration-tests/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
"playwright-test": "playwright test",
1515
"playwright-test:headed": "playwright test --headed",
1616
"playwright-test:debug": "playwright test --debug",
17-
"serve": "http-server public -p 4567"
17+
"serve": "http-server public -p 4567",
18+
"server": "http-server --port 5432",
19+
"browser": "playwright test --debug"
1820
},
1921
"installConfig": {
2022
"hoistingLimits": "workspaces"
Lines changed: 44 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,56 @@
11
import type { PlaywrightTestConfig } from '@playwright/test'
2+
import { devices } from '@playwright/test'
3+
import path from 'path'
24

3-
const PORT = 4567
5+
/**
6+
* See https://playwright.dev/docs/test-configuration.
7+
*/
48
const config: PlaywrightTestConfig = {
5-
testDir: './src/tests',
6-
timeout: 30000,
7-
retries: 1,
89
webServer: {
9-
command: 'yarn http-server public -p 4567',
10-
port: 4567,
10+
command: 'yarn run server',
11+
url: 'http://127.0.0.1:5432',
1112
reuseExistingServer: !process.env.CI,
1213
},
14+
testDir: './src/tests',
15+
globalSetup: path.resolve(__dirname, 'playwright.global-setup.ts'),
16+
/* Maximum time one test can run for. */
17+
timeout: 30 * 1000,
18+
expect: {
19+
/**
20+
* Maximum time expect() should wait for the condition to be met.
21+
* For example in `await expect(locator).toHaveText();`
22+
*/
23+
timeout: 5000,
24+
},
25+
/* Run tests in files in parallel */
26+
fullyParallel: true,
27+
/* Fail the build on CI if you accidentally left test.only in the source code. */
28+
forbidOnly: !!process.env.CI,
29+
/* Retry on CI only */
30+
retries: process.env.CI ? 2 : 0,
31+
/* Opt out of parallel tests on CI. */
32+
workers: process.env.CI ? 1 : undefined,
33+
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
34+
reporter: [['html', { open: 'never' }]],
35+
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
1336
use: {
14-
headless: true,
15-
viewport: { width: 1280, height: 720 },
16-
baseURL: `http://localhost:${PORT}`,
17-
video: {
18-
mode: 'off',
19-
size: { width: 640, height: 480 },
37+
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
38+
baseURL: `http://127.0.0.1:5432`,
39+
trace: 'on',
40+
launchOptions: {
41+
args: ['--enable-precise-memory-info', '--js-flags=--expose-gc'],
2042
},
2143
},
44+
45+
/* Configure projects for major browsers */
46+
projects: [
47+
{
48+
name: 'chromium',
49+
use: {
50+
...devices['Desktop Chrome'],
51+
},
52+
},
53+
],
2254
}
2355

2456
export default config
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import type { FullConfig } from '@playwright/test'
2+
import { execSync } from 'child_process'
3+
4+
export default function globalSetup(_cfg: FullConfig) {
5+
console.log('Executing global setup...')
6+
execSync('yarn build', { stdio: 'inherit' })
7+
console.log('Finished global setup.')
8+
}

packages/consent/consent-tools-integration-tests/src/page-objects/base-page.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ export abstract class BasePage {
104104
await this.page.route('**/settings', async (route: Route) => {
105105
await route.fulfill({
106106
status: 200,
107-
contentType: 'application/json',
108107
body: JSON.stringify(settings),
109108
})
110109
})

0 commit comments

Comments
 (0)