-
Notifications
You must be signed in to change notification settings - Fork 122
chore: add playwright fixtures package with initial configuration and … #2050
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
PupilTong
merged 2 commits into
lynx-family:main
from
PupilTong:p/hw/split-web-e2e-fixtures
Dec 25, 2025
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| { | ||
| "name": "@lynx-js/playwright-fixtures", | ||
| "version": "0.0.0", | ||
| "private": true, | ||
| "license": "Apache-2.0", | ||
| "type": "module", | ||
| "main": "src/index.ts", | ||
| "typings": "src/index.ts", | ||
| "dependencies": { | ||
| "nyc": "^17.1.0", | ||
| "v8-to-istanbul": "^9.3.0" | ||
| }, | ||
| "devDependencies": { | ||
| "@playwright/test": "^1.57.0" | ||
| }, | ||
| "peerDependencies": { | ||
| "@playwright/test": "^1.57.0" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| export * from './coverage-fixture.js'; | ||
| export * from './utils.js'; | ||
| export * from './playwright.common.js'; |
124 changes: 124 additions & 0 deletions
124
packages/web-platform/playwright-fixtures/src/playwright.common.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,124 @@ | ||
| // Copyright 2024 The Lynx Authors. All rights reserved. | ||
| // Licensed under the Apache License Version 2.0 that can be found in the | ||
| // LICENSE file in the root directory of this source tree. | ||
|
|
||
| import { type defineConfig, devices } from '@playwright/test'; | ||
| import os from 'node:os'; | ||
| import fs from 'node:fs/promises'; | ||
| import path from 'node:path'; | ||
| import { fileURLToPath } from 'node:url'; | ||
|
|
||
| const __dirname = fileURLToPath(import.meta.url); | ||
| const dir = path.join(__dirname, '..', '..', '.nyc_output'); | ||
| await fs.mkdir(dir, { recursive: true }); | ||
| process.env['LIBGL_ALWAYS_SOFTWARE'] = 'true'; // https://github.com/microsoft/playwright/issues/32151 | ||
| process.env['GALLIUM_HUD_SCALE'] = '1'; | ||
| const isCI = !!process.env['CI']; | ||
| const port = process.env['PORT'] ?? 3080; | ||
| const workerLimit = Math.floor(((cpuCount, envCPULimit) => { | ||
| if (isCI) { | ||
| if (envCPULimit) { | ||
| return envCPULimit / 2; | ||
| } else { | ||
| if (cpuCount <= 32) { | ||
| return 8; | ||
| } else { | ||
| return 8 + (cpuCount - 32) / 6; | ||
| } | ||
| } | ||
| } | ||
| return cpuCount / 2; | ||
| })(os.cpus().length, parseFloat(process.env['cpu_limit'] ?? '0'))); | ||
|
|
||
| /** | ||
| * Read environment variables from file. | ||
| * https://github.com/motdotla/dotenv | ||
| */ | ||
| // require('dotenv').config(); | ||
|
|
||
| /** | ||
| * See https://playwright.dev/docs/test-configuration. | ||
| */ | ||
| export const playwrightConfigCommon: Parameters<typeof defineConfig>[0] = { | ||
| /** global timeout https://playwright.dev/docs/test-timeouts#global-timeout */ | ||
| globalTimeout: 20 * 60 * 1000, | ||
| // testMatch, | ||
| /* Run tests in files in parallel */ | ||
| fullyParallel: true, | ||
| workers: isCI ? workerLimit : undefined, | ||
| /* Fail the build on CI if you accidentally left test.only in the source code. */ | ||
| forbidOnly: !!isCI, | ||
| /* Retry on CI only */ | ||
| retries: isCI ? 4 : 0, | ||
| // maxFailures: 16, | ||
| /* Reporter to use. See https://playwright.dev/docs/test-reporters */ | ||
| reporter: 'html', | ||
| maxFailures: isCI ? 16 : undefined, | ||
| /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ | ||
| use: { | ||
| /* Base URL to use in actions like `await page.goto('/')`. */ | ||
| baseURL: `http://localhost:${port}/`, | ||
|
|
||
| /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ | ||
| trace: 'on-first-retry', | ||
| }, | ||
|
|
||
| /** Configuration for the `expect` assertion library. */ | ||
| expect: { | ||
| /** Configuration for the `pageAssertions.toHaveScreenshot` method. */ | ||
| toHaveScreenshot: { | ||
| /** An acceptable ratio of pixels that are different to the total amount of pixels, between 0 and 1.*/ | ||
| maxDiffPixelRatio: 0.01, | ||
| }, | ||
| }, | ||
|
|
||
| /* Configure projects for major browsers */ | ||
| projects: [ | ||
| { | ||
| name: 'webkit', | ||
| use: { | ||
| ...devices['iPhone 12 Pro'], | ||
| }, | ||
| }, | ||
| { | ||
| name: 'chromium', | ||
| use: { | ||
| ...devices['Pixel 5'], | ||
| // channel: 'chromium', | ||
| launchOptions: { | ||
| // ignoreDefaultArgs: ['--headless'], | ||
| args: [ | ||
| // '--headless=new', | ||
| '--browser-ui-tests-verify-pixels', | ||
| '--browser-test', | ||
| '--font-render-hinting=none', | ||
| '--disable-skia-runtime-opts', | ||
| '--disable-font-subpixel-positioning', | ||
| '--disable-lcd-text', | ||
| '--disable-composited-antialiasing', | ||
| '--disable-system-font-check', | ||
| '--force-device-scale-factor=1', | ||
| '--touch-slop-distance=5', | ||
| '--disable-low-res-tiling', | ||
| '--disable-smooth-scrolling', | ||
| '--disable-gpu', | ||
| ], | ||
| }, | ||
| }, | ||
| }, | ||
| { | ||
| name: 'firefox', | ||
| use: { | ||
| ...devices['Desktop Firefox HiDPI'], | ||
| deviceScaleFactor: 1, | ||
| }, | ||
| }, | ||
| ].filter((e) => e), | ||
|
|
||
| /* Run your local dev server before starting the tests */ | ||
| webServer: { | ||
| command: 'npm run serve', | ||
| url: `http://localhost:${port}`, | ||
| reuseExistingServer: !isCI, | ||
| }, | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| { | ||
| "extends": "../tsconfig.json", | ||
| "compilerOptions": { | ||
| "composite": true, | ||
| "rootDir": "./src", | ||
| "outDir": "./dist", | ||
| "lib": ["ESNext", "DOM"], | ||
| "emitDeclarationOnly": true, | ||
| }, | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| "include": ["src"], | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.