Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

PackageToJS: Expose Playwright Launch Options in test harness#459

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
fjtrujy merged 1 commit intomainfromyt/expose-playwright-launch-options
Oct 21, 2025
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletionsExamples/Testing/README.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -31,3 +31,10 @@ llvm-cov show -instr-profile=.build/plugins/PackageToJS/outputs/PackageTests/def
```console
npx serve .build/coverage/html
```
## Customize test harness

See [./run-tests-with-browser-options.mjs](./run-tests-with-browser-options.mjs) for an example of customizing the test harness to run tests with specific browser options.

```console
node run-tests-with-browser-options.mjs
```
23 changes: 23 additions & 0 deletionsExamples/Testing/run-tests-with-browser-options.mjs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
// Import the generated test harness function
import { testBrowser } from "./.build/plugins/PackageToJS/outputs/PackageTests/test.js"

// Execute the test with custom browser options
async function runTest(args) {
const exitCode = await testBrowser({
args: args,
playwright: {
browser: "chromium",
launchOptions: {
headless: false,
}
}
});
if (exitCode !== 0) {
process.exit(exitCode);
}
}
// Run XCTest test suites
await runTest([]);
// Run Swift Testing test suites
await runTest(["--testing-library", "swift-testing"]);
process.exit(0);
7 changes: 7 additions & 0 deletionsPlugins/PackageToJS/Templates/test.d.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,8 +9,15 @@ export type SetupOptionsFn = (

export function testBrowser(
options: {
/** Path to the prelude script to be injected before tests run */
preludeScript?: string,
/** Command-line arguments to pass to the test runner */
args?: string[],
/** Options for Playwright browser */
playwright?: {
browser?: string,
launchOptions?: import("playwright").LaunchOptions
}
}
): Promise<number>

Expand Down
2 changes: 1 addition & 1 deletionPlugins/PackageToJS/Templates/test.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -96,7 +96,7 @@ Please run the following command to install it:
process.exit(1);
}
})();
const browser = await playwright.chromium.launch();
const browser = await playwright[options.playwright?.browser ?? "chromium"].launch(options.playwright?.launchOptions ?? {});
const context = await browser.newContext();
const page = await context.newPage();

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp