Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 7 additions & 1 deletion .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ env:
jobs:
check:
runs-on: ubuntu-latest
timeout-minutes: 10
timeout-minutes: 20
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-check
cancel-in-progress: true
Expand All @@ -29,6 +29,12 @@ jobs:
- name: Run tests
run: pnpm -w test

- name: Install Playwright browser
run: pnpm exec playwright install --with-deps chromium

- name: Run E2E tests
run: pnpm test:e2e

- name: Save PR ID
run: echo "$PR_ID" > ${{ env.PR_ID_FILE }}

Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/schedule.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
name: "Update Dependencies"

on:
schedule:
- cron: "0 13 * * 1"
workflow_dispatch: # allows us to trigger this manually
workflow_dispatch:

jobs:
update-dependencies:
Expand Down
70 changes: 51 additions & 19 deletions .syncpackrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
}
],
"versionGroups": [
{
"label": "Use Workers types v5 for ctx.access",
"packages": ["internal-sites-template"],
"dependencies": ["@cloudflare/workers-types"],
"pinVersion": "^5.20260811.1"
},
{
"label": "Pin Zod 3.x for chanfana template due to chanfana peer dep",
"packages": ["chanfana-openapi-template"],
Expand All @@ -29,12 +35,19 @@
"pinVersion": "5.4.14"
},
{
"label": "Keep React 18 for other templates",
"packages": [
"durable-chat-template",
"remix-starter-template",
"to-do-list-kv-template"
"label": "Keep React 18 for legacy Remix templates",
"packages": ["remix-starter-template", "to-do-list-kv-template"],
"dependencies": [
"react",
"react-dom",
"@types/react",
"@types/react-dom"
],
"pinVersion": "^18.0.0"
},
{
"label": "Keep React 18 for Shopify template (App Bridge + Polaris peer deps cap at 18)",
"packages": ["shopify-on-cloudflare-template"],
"dependencies": [
"react",
"react-dom",
Expand All @@ -43,6 +56,30 @@
],
"pinVersion": "^18.0.0"
},
{
"label": "Keep ESLint 8 for Shopify template (eslint-config-airbnb does not support ESLint 9)",
"packages": ["shopify-on-cloudflare-template"],
"dependencies": ["eslint"],
"pinVersion": "8.57.1"
},
{
"label": "Keep react-hooks 4 for Shopify template (eslint-config-airbnb peers eslint-plugin-react-hooks ^4.3.0)",
"packages": ["shopify-on-cloudflare-template"],
"dependencies": ["eslint-plugin-react-hooks"],
"pinVersion": "4.6.0"
},
{
"label": "Patched hono for Shopify template (GHSA-3vhc-576x-3qv4, GHSA-f67f-6cw9-8mq4, GHSA-9r54-q6cx-xmh5 affect <=4.12.33)",
"packages": ["shopify-on-cloudflare-template"],
"dependencies": ["hono"],
"pinVersion": "4.13.2"
},
{
"label": "Patched react-router-dom for Shopify template (GHSA-2w69-qvjg-hvjx, GHSA-8v8x-cx79-35w7, GHSA-49rj-9fvp-4h2h affect <=7.17.0)",
"packages": ["shopify-on-cloudflare-template"],
"dependencies": ["react-router-dom"],
"pinVersion": "7.18.2"
},
{
"label": "Allow tailwind 3.x for some templates",
"packages": [
Expand All @@ -60,21 +97,16 @@
"pinVersion": "^3.114.4"
},
{
"label": "Pin vitest 3.x for templates using @cloudflare/vitest-pool-workers",
"packages": [
"chanfana-openapi-template",
"d1-starter-sessions-api-template",
"llm-chat-app-template",
"microfrontend-template",
"mysql-hyperdrive-template",
"postgres-hyperdrive-template",
"to-do-list-kv-template",
"workers-builds-notifications-template",
"workers-for-platforms-template",
"workflows-starter-template"
],
"label": "Keep Vitest 3 for the legacy Vite 5 template",
"packages": ["to-do-list-kv-template"],
"dependencies": ["@vitest/runner", "@vitest/snapshot", "vitest"],
"pinVersion": "3.2.4"
"pinVersion": "3.2.7"
},
{
"label": "Keep the compatible Workers pool for Vitest 3",
"packages": ["to-do-list-kv-template"],
"dependencies": ["@cloudflare/vitest-pool-workers"],
"pinVersion": "0.11.1"
},
{
"label": "Set vite to v7",
Expand Down
23 changes: 19 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -401,15 +401,30 @@ Playwright is installed

2. **Basic test structure**:

<!-- prettier-ignore -->
```typescript
import { test, expect } from "@playwright/test";
import { test, expect } from "./fixtures";

test("homepage loads correctly", async ({ page }) => {
await page.goto("/");
await expect(page.locator("h1")).toBeVisible();
test("homepage loads correctly", async ({ page, templateUrl }) => {
await page.goto(templateUrl);
await expect(page.locator("h1")).toBeVisible();
});
```

3. **Use local E2E configuration for remote bindings**: If the normal `dev` script requires remote resources, add an `e2e:dev` script. The test harness prefers it automatically:

<!-- prettier-ignore -->
```json
{
"scripts": {
"dev": "wrangler dev --remote",
"e2e:dev": "wrangler dev --config wrangler.e2e.jsonc"
}
}
```

Mock only external binding boundaries; keep the production request handler in the E2E path.

### Using Playwright Codegen

Playwright's codegen feature lets you generate tests by clicking through your application:
Expand Down
19 changes: 12 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@ pnpm run test:e2e --ui
In local mode:

- Tests start development servers automatically for each template
- Uses one worker to prevent port conflicts
- Servers are properly cleaned up between different template tests
- Longer timeouts to account for build and startup time
- Servers use dynamically allocated ports, so existing local services do not conflict
- Uses one worker to keep resource usage predictable
- Servers and temporary environment files are cleaned up between template tests
- Server logs are attached to failed Playwright tests

#### Live Mode (Testing Deployed Templates)

Expand All @@ -80,10 +81,12 @@ In live mode:

The test system includes:

- **Automatic template discovery**: Finds all `*-template` directories and analyzes their framework
- **Smart server management**: Detects framework type (Astro, Next.js, Vite, etc.) and uses appropriate ports
- **Reliable cleanup**: Properly terminates process trees between test runs
- **Flexible URL resolution**: Automatically determines live URLs from `wrangler.json` configuration
- **Automatic template discovery**: Finds all `*-template` directories with a `dev` script
- **Collision-free server management**: Allocates HTTP and inspector ports dynamically
- **Reliable cleanup**: Terminates process trees and removes environment files created by the harness
- **Actionable failures**: Detects early process exits and attaches captured server logs
- **Coverage enforcement**: Fails when a dev-enabled template has no corresponding E2E spec
- **Flexible URL resolution**: Automatically determines live URLs from Wrangler configuration

### Writing Template Tests

Expand All @@ -102,6 +105,8 @@ test.describe("My Template", () => {

The `templateUrl` fixture automatically provides the correct URL (local dev server or live deployment) based on the test mode.

If a template's normal `dev` command requires remote resources, add an `e2e:dev` package script backed by local test configuration. The harness prefers `e2e:dev` when present. Keep mocks at external binding boundaries so the production request handler still runs end to end.

#### Playwright Codegen

Playwright includes a test code generation utility that records your actions in a chromium browswer. To start the codegen utility run
Expand Down
Loading
Loading