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

Commit237097a

Browse files
authored
Merge pull request#459 from swiftwasm/yt/expose-playwright-launch-options
PackageToJS: Expose Playwright Launch Options in test harness
2 parentsa31b50d +d4044cf commit237097a

File tree

4 files changed

+38
-1
lines changed

4 files changed

+38
-1
lines changed

‎Examples/Testing/README.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,10 @@ llvm-cov show -instr-profile=.build/plugins/PackageToJS/outputs/PackageTests/def
3131
```console
3232
npx serve .build/coverage/html
3333
```
34+
##Customize test harness
35+
36+
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.
37+
38+
```console
39+
node run-tests-with-browser-options.mjs
40+
```
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Import the generated test harness function
2+
import{testBrowser}from"./.build/plugins/PackageToJS/outputs/PackageTests/test.js"
3+
4+
// Execute the test with custom browser options
5+
asyncfunctionrunTest(args){
6+
constexitCode=awaittestBrowser({
7+
args:args,
8+
playwright:{
9+
browser:"chromium",
10+
launchOptions:{
11+
headless:false,
12+
}
13+
}
14+
});
15+
if(exitCode!==0){
16+
process.exit(exitCode);
17+
}
18+
}
19+
// Run XCTest test suites
20+
awaitrunTest([]);
21+
// Run Swift Testing test suites
22+
awaitrunTest(["--testing-library","swift-testing"]);
23+
process.exit(0);

‎Plugins/PackageToJS/Templates/test.d.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,15 @@ export type SetupOptionsFn = (
99

1010
exportfunctiontestBrowser(
1111
options:{
12+
/** Path to the prelude script to be injected before tests run */
1213
preludeScript?:string,
14+
/** Command-line arguments to pass to the test runner */
1315
args?:string[],
16+
/** Options for Playwright browser */
17+
playwright?:{
18+
browser?:string,
19+
launchOptions?:import("playwright").LaunchOptions
20+
}
1421
}
1522
):Promise<number>
1623

‎Plugins/PackageToJS/Templates/test.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ Please run the following command to install it:
9696
process.exit(1);
9797
}
9898
})();
99-
constbrowser=awaitplaywright.chromium.launch();
99+
constbrowser=awaitplaywright[options.playwright?.browser??"chromium"].launch(options.playwright?.launchOptions??{});
100100
constcontext=awaitbrowser.newContext();
101101
constpage=awaitcontext.newPage();
102102

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp