Skip to content

Commit c444ec0

Browse files
feat: migrate basic-host-remote e2e to Playwright (#4368)
* feat: switch basic host remote e2e to playwright * Convert Cypress example to Playwright --------- Co-authored-by: Claude <[email protected]>
1 parent ff1fa4a commit c444ec0

File tree

6 files changed

+88
-79
lines changed

6 files changed

+88
-79
lines changed

basic-host-remote/cypress.env.json

Lines changed: 0 additions & 4 deletions
This file was deleted.

basic-host-remote/e2e/checkApplications.cy.ts

Lines changed: 0 additions & 67 deletions
This file was deleted.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { test, expect } from '@playwright/test';
2+
3+
const apps = [
4+
{ port: 3001, name: 'App 1' },
5+
{ port: 3002, name: 'App 2' },
6+
];
7+
8+
apps.forEach(({ port, name }) => {
9+
test.describe(`Check ${name}`, () => {
10+
test(`Check ${name} built and running`, async ({ page }) => {
11+
await page.goto(`http://localhost:${port}`);
12+
await expect(page.getByRole('heading', { level: 1 })).toContainText('Basic Host-Remote');
13+
await expect(page.getByRole('heading', { level: 2, name })).toBeVisible();
14+
});
15+
16+
test(`Check buttons in ${name} exist`, async ({ page }) => {
17+
await page.goto(`http://localhost:${port}`);
18+
await expect(page.getByRole('button')).toHaveText('App 2 Button!!!!');
19+
});
20+
});
21+
});
22+

basic-host-remote/package.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,15 @@
1212
"build": "pnpm --filter basic-host-remote_* run build",
1313
"serve": "pnpm --filter basic-host-remote_* run serve",
1414
"clean": "pnpm --filter basic-host-remote_* run reset",
15-
"e2e:ci": "pnpm build && pnpm serve & sleep 60 && npx cypress run --config-file ../cypress-e2e/config/cypress.config.ts --config '{\"supportFile\": \"../cypress-e2e/support/e2e.ts\"}' --spec \"./e2e/*.cy.ts\" --browser=chrome"
15+
"test:e2e": "npx playwright test",
16+
"test:e2e:ui": "npx playwright test --ui",
17+
"test:e2e:debug": "npx playwright test --debug",
18+
"e2e:ci": "pnpm build && npx playwright install --with-deps && npx playwright test --reporter=list"
1619
},
1720
"devDependencies": {
1821
"concurrently": "8.2.2",
19-
"wait-on": "7.2.0"
22+
"wait-on": "7.2.0",
23+
"@playwright/test": "^1.54.2",
24+
"playwright": "^1.54.2"
2025
}
2126
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { defineConfig, devices } from '@playwright/test';
2+
3+
export default defineConfig({
4+
testDir: './e2e',
5+
timeout: 60000,
6+
expect: {
7+
timeout: 15000,
8+
},
9+
fullyParallel: true,
10+
forbidOnly: !!process.env.CI,
11+
retries: process.env.CI ? 1 : 0,
12+
workers: process.env.CI ? 1 : undefined,
13+
reporter: [
14+
['html', { outputFolder: 'playwright-report', open: 'never' }],
15+
['list'],
16+
],
17+
use: {
18+
baseURL: 'http://localhost:3001',
19+
trace: 'on-first-retry',
20+
screenshot: 'only-on-failure',
21+
video: 'retain-on-failure',
22+
viewport: { width: 1920, height: 1080 },
23+
},
24+
25+
projects: [
26+
{
27+
name: 'chromium',
28+
use: { ...devices['Desktop Chrome'] },
29+
},
30+
],
31+
32+
webServer: [
33+
{
34+
command: 'cd app1 && pnpm serve',
35+
port: 3001,
36+
reuseExistingServer: !process.env.CI,
37+
timeout: 120000,
38+
},
39+
{
40+
command: 'cd app2 && pnpm serve',
41+
port: 3002,
42+
reuseExistingServer: !process.env.CI,
43+
timeout: 120000,
44+
},
45+
],
46+
});
47+

pnpm-lock.yaml

Lines changed: 12 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)