Skip to content

Commit 97be318

Browse files
committed
[scramjet/core] fix playwright tests
1 parent b617908 commit 97be318

File tree

12 files changed

+71
-15
lines changed

12 files changed

+71
-15
lines changed

packages/scramjet/devserver.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const branch = execSync("git rev-parse --abbrev-ref HEAD", {
2727
const packagejson = JSON.parse(await fs.readFile("./package.json", "utf-8"));
2828
const version = packagejson.version;
2929

30-
const DEMO_PORT = process.env.CHROME_PORT || 4141;
30+
const DEMO_PORT = process.env.DEMO_PORT || 4141;
3131
const WISP_PORT = process.env.WISP_PORT || 4142;
3232

3333
process.env.VITE_WISP_URL =

packages/scramjet/jsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515
"types": []
1616
},
1717
"include": ["static/**/*", "dist/types/index.d.ts"],
18-
"exclude": ["node_modules", "dist", "src/**/*", "tests/**/*"]
18+
"exclude": ["node_modules", "dist", "src/**/*", "packages/core/tests/**/*"]
1919
}

packages/scramjet/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"license": "AGPL-3.0-only",
99
"packageManager": "[email protected]",
1010
"scripts": {
11+
"dev": "node --no-warnings=ExperimentalWarning devserver.ts",
1112
"preinstall": "npx only-allow pnpm"
1213
},
1314
"devDependencies": {
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import { defineConfig, devices } from "@playwright/test";
2+
import type { GitHubActionOptions } from "@estruyf/github-actions-reporter";
3+
4+
/**
5+
* See https://playwright.dev/docs/test-configuration.
6+
*/
7+
export default defineConfig({
8+
testDir: "./tests/integration/site",
9+
fullyParallel: true,
10+
forbidOnly: !!process.env.CI,
11+
retries: 2,
12+
reporter: process.env.CI
13+
? [
14+
[
15+
"@estruyf/github-actions-reporter",
16+
{
17+
title: "Test summary",
18+
useDetails: true,
19+
showError: true,
20+
} as GitHubActionOptions,
21+
],
22+
["github"],
23+
]
24+
: "html",
25+
timeout: 20000,
26+
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
27+
use: {
28+
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
29+
trace: "on-first-retry",
30+
actionTimeout: 10000,
31+
baseURL: "http://localhost:4141",
32+
},
33+
34+
/* Configure projects for major browsers */
35+
projects: [
36+
{
37+
name: "chromium",
38+
use: { ...devices["Desktop Chrome"] },
39+
},
40+
// {
41+
// name: "firefox",
42+
// use: { ...devices["Desktop Firefox"] },
43+
// },
44+
],
45+
46+
/* Run your local dev server before starting the tests */
47+
webServer: {
48+
command: "cd .. && pnpm run dev",
49+
url: "http://localhost:4141",
50+
reuseExistingServer: false,
51+
},
52+
});

packages/scramjet/tests/ci/packageValidation.js renamed to packages/scramjet/packages/core/tests/ci/packageValidation.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ import { existsSync } from "node:fs";
1414
* These aren't globs.
1515
*/
1616
const EXPECTED_DIST_FILES = [
17-
"dist/scramjet.all.js",
18-
"dist/scramjet.bundle.js",
19-
"dist/scramjet.sync.js",
17+
"dist/scramjet.js",
18+
"dist/scramjet.mjs",
19+
"dist/scramjet_bundled.js",
20+
"dist/scramjet_bundled.mjs",
2021
"dist/scramjet.wasm.wasm",
2122
];
2223

packages/scramjet/tests/util/setupPage.ts renamed to packages/scramjet/packages/core/tests/util/setupPage.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,9 @@ export async function setupPage(
1010
await page.route("**", (route) => route.continue());
1111
// Goto base url defined in config.
1212
await page.goto("/");
13-
await page.waitForSelector(".version > b");
14-
const bar = page.locator(".bar");
15-
const title = await page.locator(".version > b").textContent();
13+
await page.waitForSelector("#search");
14+
const bar = page.locator("#search");
1615
const frame = page.frameLocator("iframe");
17-
expect(title).toBe("scramjet");
1816

1917
expect(bar).not.toBeNull();
2018

packages/scramjet/packages/demo/src/App.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,12 @@ export const App: Component<
2626
this.frame.go(this.url);
2727
}}
2828
>
29-
<input type="text" value={use(this.url)} placeholder="Enter URL" />
29+
<input
30+
id="search"
31+
type="text"
32+
value={use(this.url)}
33+
placeholder="Enter URL"
34+
/>
3035
</form>
3136
<iframe this={use(this.frameel)}></iframe>
3237
</div>

0 commit comments

Comments
 (0)