Skip to content

chore: add create-test-harness-example fixture as recipes#14278

Open
edmundhung wants to merge 2 commits into
mainfrom
edmundhung/test-harness-example
Open

chore: add create-test-harness-example fixture as recipes#14278
edmundhung wants to merge 2 commits into
mainfrom
edmundhung/test-harness-example

Conversation

@edmundhung

@edmundhung edmundhung commented Jun 12, 2026

Copy link
Copy Markdown
Member

Fixes n/a.

This adds a new fixture which serves as working examples for the new createTestHarness() API and will be cross linked from cloudflare/cloudflare-docs#31422.


  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: no new feature

A picture of a cute animal (not mandatory, but encouraged)


Open in Devin Review

@changeset-bot

changeset-bot Bot commented Jun 12, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: e97082f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-project-automation github-project-automation Bot moved this to Untriaged in workers-sdk Jun 12, 2026
@workers-devprod workers-devprod requested review from a team and jamesopstad and removed request for a team June 12, 2026 11:36
@workers-devprod

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • @cloudflare/wrangler
Show detailed file reviewers
  • .github/workflows/test-and-check.yml: [@cloudflare/wrangler]
  • fixtures/create-test-harness-example/.gitignore: [@cloudflare/wrangler]
  • fixtures/create-test-harness-example/README.md: [@cloudflare/wrangler]
  • fixtures/create-test-harness-example/package.json: [@cloudflare/wrangler]
  • fixtures/create-test-harness-example/playwright.config.ts: [@cloudflare/wrangler]
  • fixtures/create-test-harness-example/tests/playwright.test.ts: [@cloudflare/wrangler]
  • fixtures/create-test-harness-example/tests/tsconfig.json: [@cloudflare/wrangler]
  • fixtures/create-test-harness-example/tests/vitest.test.ts: [@cloudflare/wrangler]
  • fixtures/create-test-harness-example/tsconfig.json: [@cloudflare/wrangler]
  • fixtures/create-test-harness-example/turbo.json: [@cloudflare/wrangler]
  • fixtures/create-test-harness-example/vite.config.ts: [@cloudflare/wrangler]
  • fixtures/create-test-harness-example/vitest.config.ts: [@cloudflare/wrangler]
  • fixtures/create-test-harness-example/workers/api/index.ts: [@cloudflare/wrangler]
  • fixtures/create-test-harness-example/workers/api/wrangler.jsonc: [@cloudflare/wrangler]
  • fixtures/create-test-harness-example/workers/web/index.ts: [@cloudflare/wrangler]
  • fixtures/create-test-harness-example/workers/web/wrangler.jsonc: [@cloudflare/wrangler]
  • pnpm-lock.yaml: [@cloudflare/wrangler]
  • pnpm-workspace.yaml: [@cloudflare/wrangler]

@ask-bonk

ask-bonk Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

UnknownError: ProviderInitError

github run

@ask-bonk

ask-bonk Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

@edmundhung Bonk workflow failed. Check the logs for details.

View workflow run · To retry, trigger Bonk again.

@ask-bonk

ask-bonk Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Confirmed: output dir is dist/<environmentName> = dist/web_worker and dist/api_worker. The playwright test paths are correct.

The fixture is internally consistent and the API usage matches the implementation. Let me do a final check on a subtle correctness concern: the vitest test relies on the shared vitest config. Wrangler's test harness spawns workerd, and the shared config might use the workers pool which could conflict. But that's an execution concern, not a logic bug I can verify statically.

Let me check one thing — the routes in wrangler.jsonc. For the web worker, route is example.com/*. In the test (vitest line 75), http://example.com/users/123 should match example.com/*. But the test also calls server.fetch("/") (line 41) which dispatches to primary worker (web). All consistent.

Let me verify there are no issues with the getDailyReport return over RPC — when a worker RPC method returns null, that's fine. The web worker checks report === null. All good.

Let me double-check one potential real issue: the api worker's scheduled deletes all user keys after generating the report (line 55-57). In the vitest "runs scheduled jobs" test, after running scheduled, it then fetches /reports/2026-05-29 which reads daily-report/. That's fine. But note the report stores userIds not user objects. The web worker joins them: "active users 123, 456". Consistent.

The PR is a well-constructed fixture. Let me verify there isn't an issue with the main tsconfig.json including config files that import from packages not in its types. Actually the only real thing worth checking: tsconfig.json excludes tests but includes everything else including vite.config.ts and vitest.config.ts which import from vitest/config and @cloudflare/vite-plugin — those have their own types, fine.

The code is correct and internally consistent. I've verified:

  • API signatures match the actual createTestHarness/TestHarness/WorkerHandle implementation
  • Output directory naming (web_worker/api_worker) correctly matches the vite plugin's workerNameToEnvironmentName hyphen-to-underscore conversion
  • Route patterns match the test dispatch expectations
  • Scheduled handler and KV logic are internally consistent
  • Workspace/catalog/workflow changes are correct

No actionable logic bugs, security issues, or API misuse found.

LGTM

github run

@edmundhung edmundhung added the ci:no-changeset-required Skip pull request checks for a valid changeset label Jun 12, 2026
devin-ai-integration[bot]

This comment was marked as resolved.

@pkg-pr-new

pkg-pr-new Bot commented Jun 12, 2026

Copy link
Copy Markdown
create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@14278

@cloudflare/deploy-helpers

npm i https://pkg.pr.new/@cloudflare/deploy-helpers@14278

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@14278

miniflare

npm i https://pkg.pr.new/miniflare@14278

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@14278

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@14278

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@14278

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@14278

@cloudflare/workers-auth

npm i https://pkg.pr.new/@cloudflare/workers-auth@14278

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@14278

@cloudflare/workers-utils

npm i https://pkg.pr.new/@cloudflare/workers-utils@14278

wrangler

npm i https://pkg.pr.new/wrangler@14278

commit: e97082f

Comment thread fixtures/create-test-harness-example/workers/web/wrangler.jsonc Outdated
devin-ai-integration[bot]

This comment was marked as resolved.

@edmundhung edmundhung force-pushed the edmundhung/test-harness-example branch from a5ea3ea to 89cd0b7 Compare June 15, 2026 13:42
@petebacondarwin petebacondarwin force-pushed the edmundhung/test-harness-example branch from 89cd0b7 to 42ebe6d Compare June 15, 2026 19:29

@petebacondarwin petebacondarwin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pnpm install seems broken.

Comment thread pnpm-workspace.yaml
@github-project-automation github-project-automation Bot moved this from Untriaged to In Review in workers-sdk Jun 15, 2026
@petebacondarwin petebacondarwin marked this pull request as draft June 15, 2026 19:59
@petebacondarwin petebacondarwin removed the request for review from jamesopstad June 15, 2026 19:59
@edmundhung edmundhung force-pushed the edmundhung/test-harness-example branch from 42ebe6d to d6da7a4 Compare June 15, 2026 20:12
@edmundhung

Copy link
Copy Markdown
Member Author

The pnpm install seems broken.

Yeah. The fixture has a dependency on workerd. So everytime we update workerd version I will need to update the lockfile again 😅

@edmundhung edmundhung marked this pull request as ready for review June 15, 2026 22:20
@edmundhung edmundhung force-pushed the edmundhung/test-harness-example branch from d6da7a4 to e97082f Compare June 17, 2026 22:43
@workers-devprod

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • @cloudflare/wrangler
Show detailed file reviewers
  • .github/workflows/test-and-check.yml: [@cloudflare/wrangler]
  • fixtures/create-test-harness-example/.gitignore: [@cloudflare/wrangler]
  • fixtures/create-test-harness-example/README.md: [@cloudflare/wrangler]
  • fixtures/create-test-harness-example/package.json: [@cloudflare/wrangler]
  • fixtures/create-test-harness-example/playwright.config.ts: [@cloudflare/wrangler]
  • fixtures/create-test-harness-example/tests/playwright.test.ts: [@cloudflare/wrangler]
  • fixtures/create-test-harness-example/tests/tsconfig.json: [@cloudflare/wrangler]
  • fixtures/create-test-harness-example/tests/vitest.test.ts: [@cloudflare/wrangler]
  • fixtures/create-test-harness-example/tsconfig.json: [@cloudflare/wrangler]
  • fixtures/create-test-harness-example/turbo.json: [@cloudflare/wrangler]
  • fixtures/create-test-harness-example/vite.config.ts: [@cloudflare/wrangler]
  • fixtures/create-test-harness-example/vitest.config.ts: [@cloudflare/wrangler]
  • fixtures/create-test-harness-example/workers/api/index.ts: [@cloudflare/wrangler]
  • fixtures/create-test-harness-example/workers/api/wrangler.jsonc: [@cloudflare/wrangler]
  • fixtures/create-test-harness-example/workers/web/index.ts: [@cloudflare/wrangler]
  • fixtures/create-test-harness-example/workers/web/wrangler.jsonc: [@cloudflare/wrangler]
  • pnpm-lock.yaml: [@cloudflare/wrangler]
  • pnpm-workspace.yaml: [@cloudflare/wrangler]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:no-changeset-required Skip pull request checks for a valid changeset

Projects

Status: In Review

Development

Successfully merging this pull request may close these issues.

3 participants