Skip to content

Commit a5686ec

Browse files
committed
tmp
1 parent 21e3cf2 commit a5686ec

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

Plugins/PackageToJS/Templates/bin/test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ Hint: This typically means that a continuation leak occurred.
9696
},
9797
browser: async ({ preludeScript }) => {
9898
const onPageLoad = (page) => {
99+
console.log("===> onPageLoad")
99100
page.exposeFunction("expectToBeTrue", () => {
100101
return true;
101102
});

Plugins/PackageToJS/Templates/test.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,16 @@ Please run the following command to install it:
100100
const context = await browser.newContext();
101101
const page = await context.newPage();
102102
// Allow the user to customize the page before it's loaded, for defining custom export functions
103-
if (options.playwright?.onPageLoad) { await options.playwright.onPageLoad(page); }
103+
if (options.playwright?.onPageLoad) {
104+
console.log("===> onPageLoad 2")
105+
await options.playwright.onPageLoad(page);
106+
}
104107

108+
// Forward console messages in the page to the Node.js console
109+
page.on("console", (message) => {
110+
console.log(message.text());
111+
});
112+
105113
const onExit = new Promise((resolve) => {
106114
page.exposeFunction("exitTest", resolve);
107115
});

Plugins/PackageToJS/Tests/ExampleTests.swift

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -411,10 +411,13 @@ extension Trait where Self == ConditionTrait {
411411
try withPackage(
412412
at: "Plugins/PackageToJS/Fixtures/PlaywrightOnPageLoadTest/XCTest",
413413
assertTerminationStatus: { $0 == 0 }
414-
) { packageDir, _, runSwift in
414+
) { packageDir, runProcess, runSwift in
415+
try runProcess(which("npm"), ["install"], [:])
416+
try runProcess(which("npx"), ["playwright", "install", "chromium-headless-shell"], [:])
417+
415418
try runSwift(
416419
["package", "--disable-sandbox"] + Self.stackSizeLinkerFlags + [
417-
"--swift-sdk", swiftSDKID, "js", "test",
420+
"--swift-sdk", swiftSDKID, "js", "test", "--environment", "browser",
418421
],
419422
[:]
420423
)
@@ -429,8 +432,14 @@ extension Trait where Self == ConditionTrait {
429432
try withPackage(
430433
at: "Plugins/PackageToJS/Fixtures/PlaywrightOnPageLoadTest/SwiftTesting",
431434
assertTerminationStatus: { $0 == 0 }
432-
) { packageDir, _, runSwift in
433-
try runSwift(["package", "--disable-sandbox", "--swift-sdk", swiftSDKID, "js", "test"], [:])
435+
) { packageDir, runProcess, runSwift in
436+
try runProcess(which("npm"), ["install"], [:])
437+
try runProcess(which("npx"), ["playwright", "install", "chromium-headless-shell"], [:])
438+
439+
try runSwift(
440+
["package", "--disable-sandbox", "--swift-sdk", swiftSDKID, "js", "test", "--environment", "browser"],
441+
[:]
442+
)
434443
}
435444
}
436445
#endif

0 commit comments

Comments
 (0)