Skip to content

test: make custom build bundling tests more robust #9494

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 12, 2025

Conversation

petebacondarwin
Copy link
Contributor

It is possible that the bundleComplete event happens before waitForBundleComplete() is called in the tests. So do that first, capture the promise, trigger the update to the build, then await the promise.


  • Tests
    • TODO (before merge)
    • Tests included
    • Tests not necessary because:
  • Wrangler / Vite E2E Tests CI Job required? (Use "e2e" label or ask maintainer to run separately)
    • I don't know
    • Required
    • Not required because: change to unit test
  • Public documentation
    • TODO (before merge)
    • Cloudflare docs PR(s):
    • Documentation not necessary because: change to unit test
  • Wrangler V3 Backport
    • TODO (before merge)
    • Wrangler PR:
    • Not necessary because: change to unit test

It is possible that the bundleComplete event happens before `waitForBundleComplete()` is called in the tests.
So do that first, capture the promise, trigger the update to the build, then await the promise.
@petebacondarwin petebacondarwin requested a review from a team as a code owner June 5, 2025 11:06
Copy link

changeset-bot bot commented Jun 5, 2025

⚠️ No Changeset found

Latest commit: c5b8251

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

Copy link
Contributor

github-actions bot commented Jun 5, 2025

A Wrangler prerelease is available for testing. You can install this latest build in your project with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/15465432513/npm-package-wrangler-9494
Prereleases for other packages:

cloudflare-workers-bindings-extension:

wget https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/15465432513/npm-package-cloudflare-workers-bindings-extension-9494 -O ./cloudflare-workers-bindings-extension.0.0.0-v8feb08475.vsix && code --install-extension ./cloudflare-workers-bindings-extension.0.0.0-v8feb08475.vsix

create-cloudflare:

npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/15465432513/npm-package-create-cloudflare-9494 --no-auto-update

@cloudflare/kv-asset-handler:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/15465432513/npm-package-cloudflare-kv-asset-handler-9494

miniflare:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/15465432513/npm-package-miniflare-9494

@cloudflare/pages-shared:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/15465432513/npm-package-cloudflare-pages-shared-9494

@cloudflare/unenv-preset:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/15465432513/npm-package-cloudflare-unenv-preset-9494

@cloudflare/vite-plugin:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/15465432513/npm-package-cloudflare-vite-plugin-9494

@cloudflare/vitest-pool-workers:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/15465432513/npm-package-cloudflare-vitest-pool-workers-9494

@cloudflare/workers-editor-shared:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/15465432513/npm-package-cloudflare-workers-editor-shared-9494

@cloudflare/workers-shared:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/15465432513/npm-package-cloudflare-workers-shared-9494

@cloudflare/workflows-shared:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/15465432513/npm-package-cloudflare-workflows-shared-9494

Note that these links will no longer work once the GitHub Actions artifact expires.

@@ -435,12 +435,13 @@ describe("BundleController", () => {
legacy: {},
};

let evCustomPromise = waitForBundleComplete(controller);
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe add a comment to explain the ordering?

Copy link
Contributor

@vicb vicb left a comment

Choose a reason for hiding this comment

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

LGTM - a code comment could help

@github-project-automation github-project-automation bot moved this from Untriaged to Approved in workers-sdk Jun 10, 2025
@petebacondarwin petebacondarwin added this pull request to the merge queue Jun 12, 2025
Merged via the queue into main with commit b8331b0 Jun 12, 2025
31 of 32 checks passed
@petebacondarwin petebacondarwin deleted the pbd/wrangler/test-improvement branch June 12, 2025 15:00
@github-project-automation github-project-automation bot moved this from Approved to Done in workers-sdk Jun 12, 2025
jseba added a commit to jseba/workers-sdk that referenced this pull request Jun 14, 2025
* 'main' of ssh://github.com/cloudflare/workers-sdk: (213 commits)
  fix(vite-plugin-cloudflare): allow unknown entrypoint on startup (cloudflare#9583)
  add warning about env not specified to potentially risky wrangler commands (cloudflare#9344)
  test: correctly delete test d1 databases (cloudflare#9598)
  Add details to v3 maintenance worflow error message (cloudflare#9602)
  drop unused `WRANGLER_UNENV_RESOLVE_PATHS` env var (cloudflare#9593)
  warn instead of erroring if no exposed ports. and remove unused dev_exposed_ports (cloudflare#9573)
  fix(wrangler): point to the right doc location (replaces cloudflare#9353) (cloudflare#9592)
  [vitest-pool-worker] Add `type: module` in package.json (cloudflare#9595)
  Enable HTML handling for HTML files in the public directory (cloudflare#9548)
  switch from go container to js (cloudflare#9588)
  containers: switch to Cloudflare container registry (cloudflare#9564)
  performance improvement: restart a mixed mode session only if the worker's remote bindings have changed (cloudflare#9536)
  ci: delete more orphaned resources from e2e tests (cloudflare#9580)
  test: remove `verifyBuildScript` logic from c3 e2e tests (cloudflare#9504)
  fix(vite-plugin): ensure node compat globals are injected before any imports (cloudflare#9581)
  feat(containers-shared): Move `isDockerfile` utility function to `containers-shared` (cloudflare#9577)
  allow `startWorker` to accept `false` as an `inspector` option (to disable the inspector server) (cloudflare#9550)
  Update capnp generated code from the workerd.capnp (cloudflare#9582)
  Bump `@cloudflare/unenv-preset` to 2.3.3 (cloudflare#9566)
  test: make custom build bundling tests more robust (cloudflare#9494)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants