Files
wehub-resource-sync 70bf21e064
Deploy (to testing) and Test Playground Preview Worker / Deploy Playground Preview Worker (testing) (push) Has been skipped
Deploy Workers Shared Staging / Deploy Workers Shared Staging (push) Failing after 0s
Prerelease / build (push) Has been skipped
Handle Changesets / Handle Changesets (push) Has been cancelled
Semgrep OSS scan / semgrep-oss (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:30:11 +08:00

299 KiB

@cloudflare/vitest-pool-workers

0.18.4

Patch Changes

  • #14535 1b965c5 Thanks @Naapperas! - Support dynamic retry delays for Workflow steps in local dev

    A step's retries.delay can now be a function that computes the delay per failed attempt, in addition to a static duration. The function receives { ctx, error } and returns a delay (a number of milliseconds or a duration string like "30 seconds"), and its result is fed into the configured backoff.

    await step.do(
      "call flaky API",
      {
        retries: {
          limit: 5,
          backoff: "constant",
          delay: ({ ctx }) => ctx.attempt * 1000,
        },
      },
      async () => {
        /* ... */
      }
    );
    

    The function is invoked once per failed attempt with a 5 second timeout. If it throws, times out, or returns an invalid value, the step fails without further retries.

  • Updated dependencies [0283a1f, 7b28392, 1b965c5]:

0.18.3

Patch Changes

0.18.2

Patch Changes

0.18.1

Patch Changes

0.18.0

Minor Changes

  • #14382 fd92d56 Thanks @petebacondarwin! - Add support for declarative Durable Object exports

    wrangler deploy now accepts an exports map in wrangler.json as a declarative alternative to the legacy migrations array.

    Each entry in exports is keyed by Durable Object class name. type carries the export kind (currently always "durable-object"); the state field carries the lifecycle and defaults to "created" (live) when omitted:

    {
      "exports": {
        // Provision a new Durable Object class (`MyDO`)
        "MyDO": { "type": "durable-object", "storage": "sqlite" },
        // Delete Durable Object class (`OldGone`)
        "OldGone": { "type": "durable-object", "state": "deleted" },
        // Rename a Durable Object class (from `OldName` to `NewName`)
        "OldName": {
          "type": "durable-object",
          "state": "renamed",
          "renamed_to": "NewName"
        },
        "NewName": { "type": "durable-object", "storage": "sqlite" },
        // Transfer a Durable Object (`Outgoing`) to a new Worker (`target-worker`)
        "Outgoing": {
          "type": "durable-object",
          "state": "transferred",
          "transferred_to": "target-worker"
        },
        // Prepare to receive the transfer of a Durable Object (`Incoming`) from another Worker (`source-worker`)
        "Incoming": {
          "type": "durable-object",
          "state": "expecting-transfer",
          "storage": "sqlite",
          "transfer_from": "source-worker"
        }
      }
    }
    

    When a Worker declares Durable Object class bindings but no lifecycle for them (neither a migrations array nor an exports map), wrangler warns and now suggests a declarative exports entry for each class (previously it suggested a legacy migrations block).

    The deployment response now surfaces the server's reconciliation result — created namespaces, applied tombstones, structured per-scenario info entries, and a removable_entries hint for stale tombstones that are safe to delete from the config. Blocking errors return the structured per-class detail with scenario tags, suggested remediation, and any referencing-script context.

    wrangler versions upload also forwards exports. Declarative exports lifecycle changes are reconciled when the version is deployed (wrangler versions deploy or wrangler deploy), so a versions upload payload can declare new classes in exports without immediately provisioning them. An actor binding (durable_objects.bindings) to a class declared only in exports on the same versions upload is rejected with a clear error (code 100406) — the binding cannot be resolved until the namespace is provisioned. Either stage the new class via ctx.exports.X (no binding required) on versions upload and add the binding at deploy time, or use wrangler deploy to provision and bind in one step (the same constraint applies to the migrations flow).

    Multi-version deploys (wrangler versions deploy A@50% B@50%) where the selected versions disagree on declarative exports are rejected server-side with a clear message: deploy the version that changes exports at 100% first, then run the percentage-split deploy. This prevents traffic on one branch routing to code that references unprovisioned or just-deleted DO namespaces. Single-version (100%) deploys are unaffected.

    Local development (wrangler dev, vite dev and unstable_startWorker) reads Durable Object SQLite storage settings from the new exports field, so applications using the declarative flow get correct local-dev storage without needing to also declare a migrations block.

    @cloudflare/vitest-pool-workers also picks up Durable Object configuration from exports, so tests against an exports-only Worker run with the correct local SQLite storage and can reach unbound Durable Object classes via ctx.exports.X.

    wrangler types is also aware of exports. Live entries (including expecting-transfer, the receiving side of a two-phase transfer) are added to Cloudflare.GlobalProps.durableNamespaces, which types ctx.exports.X for unbound Durable Objects declared only via exports.

Patch Changes

0.17.0

Minor Changes

  • #14490 75d8cb0 Thanks @petebacondarwin! - Make Workflow introspector get() async

    The introspectWorkflow(...).get() method now returns a promise, so callers must await it:

    const introspector = await introspectWorkflow(env.MY_WORKFLOW);
    
    // Before
    const instances = introspector.get();
    
    // After
    const instances = await introspector.get();
    

    This aligns Workflow introspection with the shared implementation used by createTestHarness().

Patch Changes

  • #14490 75d8cb0 Thanks @petebacondarwin! - Support require("./x.wasm?module") in CommonJS dependencies

    Previously, only literal await import("./x.wasm?module") specifiers were rewritten through the static analysis path added in #11094. CommonJS dependencies that use require("./x.wasm?module") reach the module-fallback service at runtime, where the ?module suffix went unhandled. The fallback either failed with No such module "<abs>/x.wasm?module" or, when a CompiledWasm rule was configured, attempted to evaluate the WebAssembly bytes as JavaScript.

    However, these require()s work in deployed workers because esbuild's bundler statically rewrites these require() calls into ES dynamic imports. vitest-pool-workers' Vite-based pipeline doesn't do that rewrite and instead defers to the module-fallback at runtime.

    The module-fallback now strips ?module from the resolved target and synthesizes a CommonJS wrapper that re-requires the underlying .wasm by absolute path, exposing it on default to match what workerd produces for CompiledWasm modules.

  • Updated dependencies [75d8cb0, 75d8cb0, 75d8cb0, 75d8cb0, 75d8cb0, f10d4ad, 75d8cb0, 75d8cb0, 75d8cb0, 75d8cb0, d292046, 75d8cb0, 75d8cb0, 75d8cb0, 75d8cb0, 75d8cb0, 75d8cb0, e0cc2cb, 75d8cb0, 75d8cb0, 75d8cb0]:

0.16.20

Patch Changes

  • #14398 c5014cc Thanks @apeacock1991! - Add evictDurableObject and evictAllDurableObjects test helpers to cloudflare:test

    These helpers let you exercise how a Durable Object behaves across evictions in your tests. Eviction is graceful: durable storage is preserved, in-memory state is reset by tearing down the instance, hibernatable WebSockets are hibernated rather than closed, and eviction waits for in-flight requests to drain.

    import { evictDurableObject, evictAllDurableObjects } from "cloudflare:test";
    import { env } from "cloudflare:workers";
    
    const id = env.COUNTER.idFromName("my-counter");
    const stub = env.COUNTER.get(id);
    
    // Evict the Durable Object instance pointed to by a specific stub
    await evictDurableObject(stub);
    await evictDurableObject(stub, { webSockets: "close" });
    
    // Evict all currently-running Durable Objects in evictable namespaces
    await evictAllDurableObjects();
    
  • #14394 8a5cf8c Thanks @Partha-Shankar! - fix(d1): escape migrationsTableName and filenames in SQLite queries

    D1 migration commands in both wrangler and @cloudflare/vitest-pool-workers interpolated the migrationsTableName config value and migration filenames directly into SQL strings without any escaping. This meant:

    • A table name such as my"table would produce invalid SQL in CREATE TABLE, SELECT, and INSERT statements, and
    • A migration filename containing an apostrophe (e.g. what's-new.sql) would break the INSERT INTO ... VALUES ('...') statement appended after each migration in wrangler.

    Both identifiers are now properly escaped before interpolation: migrationsTableName is wrapped in double-quotes with internal double-quotes doubled (SQL-standard identifier quoting), and migration filenames used as string literals have their single-quotes doubled before insertion.

  • Updated dependencies [5f40dd5, 34e0cef, 3b743c1, daa5389, 8a5cf8c]:

0.16.19

Patch Changes

0.16.18

Patch Changes

0.16.17

Patch Changes

0.16.16

Patch Changes

0.16.15

Patch Changes

0.16.14

Patch Changes

0.16.13

Patch Changes

0.16.12

Patch Changes

  • #14152 3d7992e Thanks @petebacondarwin! - Fix module resolution failing when project path contains spaces

    When a project lived under a directory with spaces (e.g. /Users/me/Documents/Master CMS/project), the vitest pool would fail with No such module "threads.js" before any test executed. The module fallback service now uses the rawSpecifier from workerd's fallback request to correctly decode file:// URLs, avoiding the double-encoding of spaces (%20%2520) that occurred when workerd resolved these URLs as relative paths.

  • #14105 337e912 Thanks @dario-piotrowicz! - Remove trailing periods from URLs in terminal output

    URLs printed to the terminal with a sentence-ending period (e.g. https://example.com/path.) would include the period when clicked in some terminal emulators, causing 404 errors. This removes trailing periods from all URLs displayed in CLI output across wrangler, miniflare, vitest-pool-workers, and workers-utils.

  • #14112 3a746ac Thanks @penalosa! - Pin non-bundled runtime dependencies to exact versions

    Dependencies that are not bundled into a package's published output are installed directly into consumers' dependency trees, so they are now pinned to exact versions instead of semver ranges. This closes a supply-chain gap where an unpinned external dependency could resolve to a compromised upstream release on a fresh install. A new pnpm check:pinned-deps lint enforces this for all published packages (and for the shared pnpm catalog) going forward.

  • #14061 da8e306 Thanks @Vardiak! - Preserve Durable Object WebSocket handler invocation order

    Durable Object WebSocket events could begin executing out of order in the Workers Vitest integration when several events arrived while the test wrapper was resolving user code.

    Handler invocation now preserves arrival order while still allowing asynchronous handler completion to run concurrently.

  • Updated dependencies [b210c5e, aec1bb8, e06cbb7, 9a26191, 5565823, 4ef790b, 890fca7, 6fc9777, 337e912, 8e7b74f, e86489a, 42288d4, 65b5f9e, 3a746ac, 64ef9fd, 94b29f7]:

0.16.11

Patch Changes

0.16.10

Patch Changes

0.16.9

Patch Changes

  • #13933 90092c0 Thanks @petebacondarwin! - Derive bundler externals from package.json and shrink the published bundle

    The bundler's external list was previously hand-maintained and out of sync with package.jsonundici and semver were both listed as external despite being only devDependencies. The published dist/pool/index.mjs consequently contained a top-level import { fetch } from "undici" that was only resolvable because pnpm happened to hoist undici from other packages' devDependencies during local development.

    The bundler now derives its external list from dependencies + peerDependencies in package.json, making it impossible for a devDependency to silently end up externalized.

    Combined with the new "sideEffects": false declaration in @cloudflare/workers-utils, the unused cloudflared / tunnel exports (and their transitive undici import) are now tree-shaken out of the pool entirely. dist/pool/index.mjs no longer references undici at all, and shrinks from ~489 KB to ~125 KB.

  • Updated dependencies [52e9082, 0733688, fc1f7b9, 30657e1, 8c569c6, f598eac, 3a1fbed]:

0.16.8

Patch Changes

  • #13919 c7eab7f Thanks @petebacondarwin! - Fix the outbound CF-Worker header reflecting the route pattern hostname instead of the parent zone, and falling back to <worker-name>.example.com under vite dev, vitest-pool-workers, and getPlatformProxy

    Two related issues affected the CF-Worker header on outbound subrequests in local development:

    1. Under @cloudflare/vite-plugin, @cloudflare/vitest-pool-workers, and getPlatformProxy, the header fell back to <worker-name>.example.com even when routes were configured, because unstable_getMiniflareWorkerOptions and the equivalent getPlatformProxy worker-options path did not propagate a zone value to Miniflare. This broke local development against services that reject unknown CF-Worker hosts (for example, Apple WeatherKit returns 403 Forbidden).
    2. Across the above paths and wrangler dev --local, when a route used the zone_name field (for example { pattern: "foo.example.com/*", zone_name: "example.com" }), the header was set to the pattern's hostname (foo.example.com) rather than the zone name (example.com). Production sets CF-Worker to the zone name that owns the Worker, so this was inconsistent with deployed behaviour.

    Both bugs are fixed: the new unstable_getMiniflareWorkerOptions / getPlatformProxy path now propagates a zone derived from the first configured route, and all four local-dev paths now prefer a route's explicit zone_name over the pattern hostname when computing that zone. When zone_name isn't set, the existing best-effort behaviour is preserved — for wrangler dev this means dev.host is still honoured as a local override and the pattern hostname is used as a final fallback. Resolving the parent zone for zone_id-only, custom_domain, or plain-string routes would require an API lookup, so locally we still approximate it with the pattern hostname.

    Note: dev.host is intentionally not consulted by the unstable_getMiniflareWorkerOptions / getPlatformProxy paths — the dev config block is specific to wrangler dev.

  • Updated dependencies [fa1f61f, 2679e05, 7e40d98, adc9221, 735852d, d803737, c7eab7f, e04e180, 59cd880, 62abf97, e8c2031, e349fe0, da0fa8c, a5c9365]:

0.16.7

Patch Changes

0.16.6

Patch Changes

  • #13833 0e4a830 Thanks @thegeekasteroid! - Filter benign disconnected: WebSocket peer disconnected workerd stderr noise during test runs.

    The ignoreMessages array in the pool already filters several benign workerd disconnect messages (e.g. disconnected: WebSocket was aborted). On recent workerd versions, tests that exercise the WebSocket API also surface disconnected: WebSocket peer disconnected warnings during normal teardown. These are not user-actionable and obscure real test failures. Add the message to the existing filter alongside the other disconnected: entries.

  • Updated dependencies [19ed49a, 3ff0a50, bf688f7, 2e72c83, 802eaf4, 506aa02, 8f5cdb1, be8a98c]:

0.16.5

Patch Changes

0.16.4

Patch Changes

0.16.3

Patch Changes

0.16.2

Patch Changes

0.16.1

Patch Changes

0.16.0

Minor Changes

  • #13810 2b8c0cc Thanks @jamesopstad! - Stabilize the secrets configuration property

    The secrets property in the Wrangler config file is no longer experimental and will no longer emit an experimental warning when used. Required secrets are validated during local development and deploy, and used as the source of truth for type generation.

    {
      "secrets": {
        "required": ["API_KEY", "DB_PASSWORD"]
      }
    }
    

Patch Changes

  • #12974 1127114 Thanks @ask-bonk! - Rewrite self-referencing service bindings to kCurrentWorker before renaming the runner worker

    When a wrangler config has a service binding to itself (e.g. services: [{ binding: "SELF", service: "my-worker" }] where the worker is named "my-worker"), the binding's literal name pointed to a worker that no longer existed once vitest-pool-workers renamed the runner to vitest-pool-workers-runner-<project>. The self-reference is now rewritten to the miniflare kCurrentWorker symbol, which resolves at request time relative to the referer worker and so survives the rename. Previously this rewrite lived in wrangler's unstable_getMiniflareWorkerOptions, but it's only needed for vitest-pool-workers' rename — other consumers (getPlatformProxy, @cloudflare/vite-plugin) preserve the original worker name and so don't need it.

  • Updated dependencies [e07825a, 58899d8, 3020214, 0099265, 25f5ef2, bb27219, 194d75e, 12fb5db, 18b9d5b, 9f532f7, 1127114, 3ceadef, 2b8c0cc, 1a5cc86]:

0.15.2

Patch Changes

0.15.1

Patch Changes

0.15.0

Minor Changes

  • #13623 b156b2e Thanks @penalosa! - Add reset() and abortAllDurableObjects() helpers to cloudflare:test

    The reset() helper deletes all data from attached bindings, and resets all Durable Object instances. This is useful for resetting state between test blocks.

    The abortAllDurableObjects() helper resets all Durable Object instances without deleting persisted data.

    import { reset } from "cloudflare:test";
    import { afterEach } from "vitest";
    
    afterEach(async () => {
      await reset();
    });
    

Patch Changes

0.14.9

Patch Changes

0.14.8

Patch Changes

  • #13548 1aee990 Thanks @emily-shen! - Update warning message when attempting to access exports not defined on the main worker

    Previously this referred to the SELF worker, which is now a deprecated API in the Vitest integration.

  • #13607 d5d0446 Thanks @petebacondarwin! - fix: Restore workflow binding before async cleanup in WorkflowIntrospectorHandle.dispose()

    Previously, dispose() awaited all instance abort operations before restoring the original env binding. On slower CI environments (especially Windows), this left a window where the next test could see a stale proxy, causing "Trying to mock step multiple times" errors or failed introspection. The binding is now restored synchronously before the async instance cleanup begins.

  • #13007 2c3258d Thanks @sheplu! - Reduce default log verbosity from VERBOSE to INFO

    The pool logger was previously hardcoded to VERBOSE, causing noisy debug messages on every test run (e.g. [vpw:debug] Adding compatibility flag...). Only informational, warning, and error messages are now printed by default.

    For debugging, set NODE_DEBUG=vitest-pool-workers to restore the detailed output.

  • Updated dependencies [05f4443, 4a9ba90, d8c895a, b35617b, 7dc0433, 8ca78bb, b6e1351, d8314c6, b35617b, 7f50300, 4fda685, be5e6a0, e456952, 59eec63, 50bf819, cc1413a, d0a9d1c, 4eb1da9, 8ca78bb, 266c418, 6d887db, 5716d69]:

0.14.7

Patch Changes

0.14.6

Patch Changes

0.14.5

Patch Changes

0.14.4

Patch Changes

0.14.3

Patch Changes

0.14.2

Patch Changes

  • #13095 65e6684 Thanks @penalosa! - Reject V8 coverage provider with a clear error message

    V8 native code coverage (@vitest/coverage-v8) requires node:inspector to collect profiling data from V8's runtime. workerd only provides node:inspector as a non-functional stub, so V8 coverage would silently fail or crash with a confusing No such module "node:inspector" error.

    The pool now detects this configuration early — during Vite plugin setup, before Vitest tries to load the coverage provider — and throws a clear error directing users to use Istanbul coverage instead, which works by instrumenting source code at build time and runs on any JavaScript runtime.

  • Updated dependencies [a3e3b57, 7d318e1, fa6d84f, 96ee5d4, 7d318e1, 7a60d4b, 78cbe37, 6fa5dfd]:

0.14.1

Patch Changes

  • #13131 65acf66 Thanks @dario-piotrowicz! - Use miniflare's handleStructuredLogs option instead of handleRuntimeStdio for processing workerd output

    Previously, vitest-pool-workers manually processed raw stdout/stderr streams from the workerd runtime via handleRuntimeStdio, with its own filtering of known noisy messages (e.g. LLVM symbolizer warnings). This switches to miniflare's handleStructuredLogs option, which parses workerd's structured JSON log output and automatically filters known unhelpful messages. This aligns with how both wrangler and vite-plugin-cloudflare handle workerd logs.

  • Updated dependencies [9c4035b, 5d29055, fb67a18, d5bffde, ab44870, 48d83ca, b2f53ea, b9b7e9d, 14e72eb, 4dc94fd, b2f53ea, d5bffde, 48d83ca]:

0.14.0

Minor Changes

  • #12858 f05f2da Thanks @repository! - Add disableRetryDelays() to WorkflowInstanceModifier to skip retry backoff delays in tests

    When testing Workflows with retry configurations, the backoff delays between retry attempts of a failing step.do() caused real wall-clock waiting (e.g., 35 seconds for 3 retries with 5-second exponential backoff), even when step results were fully mocked. The new disableRetryDelays() method eliminates these delays while preserving retry behavior — all attempts still execute, just without waiting between them.

Patch Changes

0.13.5

Patch Changes

  • #13077 11c77b7 Thanks @penalosa! - fix: runInDurableObject now correctly returns redirect responses (3xx) from Durable Object callbacks instead of throwing "Expected callback for X" errors

  • #13056 8384743 Thanks @penalosa! - fix: Support dynamic import() inside entrypoint and Durable Object handlers

    Previously, calling exports.default.fetch() or SELF.fetch() on a worker whose handler used a dynamic import() would hang and fail with "Cannot perform I/O on behalf of a different Durable Object". This happened because the module runner's transport — which communicates over a WebSocket owned by the runner Durable Object — was invoked from a different DO context.

    The fix patches the module runner's transport via the onModuleRunner hook so that all invoke() calls are routed through the runner DO's I/O context, regardless of where the import() originates.

  • #13074 4618c05 Thanks @penalosa! - fix: only apply module fallback extension probing for require(), not import

    The module fallback service previously tried adding .js, .mjs, .cjs, and .json suffixes to extensionless specifiers unconditionally. Per the Node.js spec, this extension-probing behaviour is specific to CommonJS require(). ESM import statements must include explicit file extensions.

    Extension-less TypeScript import specifiers continue to work correctly — they are resolved by Vite's resolver rather than the fallback's extension loop.

  • #13073 baec845 Thanks @penalosa! - Add adminSecretsStore() to cloudflare:test for seeding secrets in tests

    Secrets store bindings only expose a read-only .get() method, so there was previously no way to seed secret values from within a test. The new adminSecretsStore() helper returns Miniflare's admin API for a secrets store binding, giving tests full control over create, update, and delete operations.

    import { adminSecretsStore } from "cloudflare:test";
    import { env } from "cloudflare:workers";
    
    const admin = adminSecretsStore(env.MY_SECRET);
    await admin.create("test-value");
    
    const value = await env.MY_SECRET.get(); // "test-value"
    
  • #13083 cfd513f Thanks @penalosa! - Add a 30-second timeout to waitUntil promise draining to prevent hanging tests

    Previously, if a ctx.waitUntil() promise never resolved, the test suite would hang indefinitely after the test file finished. Now, any waitUntil promises that haven't settled within 30 seconds are abandoned with a warning, allowing the test suite to continue. This aligns with the production waitUntil limit.

  • Updated dependencies [eeaa473, 9fcdfca, bc24ec8, 1faff35, 0b4c21a, 535582d, 992f9a3, f4ea4ac, 91b7f73, f6cdab2, 53ed15a, ce65246, 7a5be20, 6b50bfa, 0386553, 9c5ebf5, 53ed15a, 53ed15a]:

0.13.4

Patch Changes

0.13.3

Patch Changes

0.13.2

Patch Changes

0.13.1

Patch Changes

0.13.0

Minor Changes

  • #11632 a6ddbdb Thanks @penalosa! - Support Vitest 4 in @cloudflare/vitest-pool-workers.

    This a breaking change to the @cloudflare/vitest-pool-workers integration in order to support Vitest v4. Along with supporting Vitest v4 (and dropping support for Vitest v2 and v3), we've made a number of changes that may require changes to your tests. Our aim has been to improve stability & the foundations of @cloudflare/vitest-pool-workers as we move towards a v1 release of the package.

    We've made a codemod to make the migration easier, which will make the required changes to your config file:

    npx jscodeshift -t node_modules/@cloudflare/vitest-pool-workers/dist/codemods/vitest-v3-to-v4.mjs vitest.config.ts
    

    Or, without installing the package first:

    npx jscodeshift -t https://unpkg.com/@cloudflare/vitest-pool-workers/dist/codemods/vitest-v3-to-v4.mjs --parser=ts vitest.config.ts
    
    • Config API: defineWorkersProject and defineWorkersConfig from @cloudflare/vitest-pool-workers/config have been replaced with a cloudflareTest() Vite plugin exported from @cloudflare/vitest-pool-workers. The test.poolOptions.workers options are now passed directly to cloudflareTest():

      Before:

      import { defineWorkersProject } from "@cloudflare/vitest-pool-workers/config";
      
      export default defineWorkersProject({
        test: {
          poolOptions: {
            workers: {
              wrangler: { configPath: "./wrangler.jsonc" },
            },
          },
        },
      });
      

      After:

      import { cloudflareTest } from "@cloudflare/vitest-pool-workers";
      import { defineConfig } from "vitest/config";
      
      export default defineConfig({
        plugins: [
          cloudflareTest({
            wrangler: { configPath: "./wrangler.jsonc" },
          }),
        ],
      });
      
    • isolatedStorage & singleWorker: These have been removed in favour of a simpler isolation model that more closely matches Vitest. Storage isolation is now on a per test file basis, and you can make your test files share the same storage by using the Vitest flags --max-workers=1 --no-isolate

    • import { env, SELF } from "cloudflare:test": These have been removed in favour of import { env, exports } from "cloudflare:workers". exports.default.fetch() has the same behaviour as SELF.fetch(), except that it doesn't expose Assets. To test your assets, write an integration test using startDevWorker()

    • import { fetchMock } from "cloudflare:test": This has been removed. Instead, mock globalThis.fetch or use ecosystem libraries like MSW (recommended).

    • Vitest peer dependency: @cloudflare/vitest-pool-workers now requires vitest@^4.1.0.

Patch Changes

0.12.21

Patch Changes

0.12.20

Patch Changes

0.12.19

Patch Changes

0.12.18

Patch Changes

0.12.17

Patch Changes

0.12.16

Patch Changes

0.12.15

Patch Changes

0.12.14

Patch Changes

0.12.13

Patch Changes

0.12.12

Patch Changes

0.12.11

Patch Changes

0.12.10

Patch Changes

0.12.9

Patch Changes

0.12.8

Patch Changes

0.12.7

Patch Changes

  • #12056 6d5f69f Thanks @edmundhung! - fix: allow Vite query parameters like ?raw on .sql file imports

    Importing .sql files with Vite query parameters (e.g., import sql from "./query.sql?raw") would fail with "No such module" errors in vitest-pool-workers 0.12.x. Both import styles now work:

    • import sql from "./query.sql?raw" (Vite handles the ?raw transform)
    • import sql from "./query.sql" (loaded as Text module)
  • #11917 7b40ceb Thanks @ksawaneh! - Fix CommonJS require() of .json files in the module fallback service (avoids SyntaxError: Unexpected token ':').

  • #11897 bbd8a5e Thanks @dario-piotrowicz! - Bundle the zod dependency to reduce supply chain attack surface

    In order to prevent possible npm vulnerability attacks, the team's policy is to bundle dependencies in our packages where possible. This helps ensure that only trusted code runs on the user's system, even if compromised packages are later published to npm.

    This change bundles zod (a pure JavaScript validation library with no native dependencies) into miniflare and @cloudflare/vitest-pool-workers.

    Other dependencies remain external for technical reasons:

    • sharp: Native binary with platform-specific builds
    • undici: Dynamically required at runtime in worker threads
    • ws: Has optional native bindings for performance
    • workerd: Native binary (Cloudflare's JavaScript runtime)
    • @cspotcode/source-map-support: Uses require.cache manipulation at runtime
    • youch: Dynamically required for lazy loading
  • Updated dependencies [a0a9ef6, ad4666c, 014e7aa, e414f05, 77e82d2, f08ef21, 0641e6c, eacedba, 05714f8, e8b2ef5, bbd8a5e]:

0.12.6

Patch Changes

0.12.5

Patch Changes

0.12.4

Patch Changes

  • #11898 c17e971 Thanks @petebacondarwin! - Bundle more third-party dependencies to reduce supply chain risk

    Previously, several small utility packages were listed as runtime dependencies and installed separately. These are now bundled directly into the published packages, reducing the number of external dependencies users need to trust.

    Bundled dependencies:

    • miniflare: acorn, acorn-walk, exit-hook, glob-to-regexp, stoppable
    • kv-asset-handler: mime
    • vite-plugin-cloudflare: @remix-run/node-fetch-server, defu, get-port, picocolors, tinyglobby
    • vitest-pool-workers: birpc, devalue, get-port, semver
  • Updated dependencies [e78186d, fe4faa3, 4714ca1, c17e971, 695b043]:

0.12.3

Patch Changes

0.12.2

Patch Changes

0.12.1

Patch Changes

0.12.0

Minor Changes

  • #11648 eac5cf7 Thanks @pombosilva! - Add Workflows test handlers in vitest-pool-workers to get the Workflow instance output and error:

    • getOutput(): Returns the output of the successfully completed Workflow instance.
    • getError(): Returns the error information of the errored Workflow instance.

    Example:

    // First wait for the workflow instance to complete:
    await expect(
      instance.waitForStatus({ status: "complete" })
    ).resolves.not.toThrow();
    
    // Then, get its output
    const output = await instance.getOutput();
    
    // Or for errored workflow instances, get their error:
    await expect(
      instance.waitForStatus({ status: "errored" })
    ).resolves.not.toThrow();
    const error = await instance.getError();
    

Patch Changes

0.11.1

Patch Changes

0.11.0

Minor Changes

  • #11533 8d9003e Thanks @petebacondarwin! - Add support for ctx.exports

    It is now possible to access ctx.exports properties for the main (SELF) worker.

    • Integration tests: in the SELF worker the ctx.exports object now contains the expected stubs to the exported entry-points.
    • Unit tests: the object returned from createExecutionContext() has exports property that exposes the exports of the SELF worker.

    Due to the dynamic nature of Vitest the integration relies upon guessing what the exports of the main Worker are by statically analyzing the Worker source using esbuild. In cases where it is not possible to infer the exports (for example, a wildcard re-export of a virtual module) it is possible to declare these in the vitest-pool-workers config via the additionalExports setting.

Patch Changes

0.10.15

Patch Changes

0.10.14

Patch Changes

0.10.13

Patch Changes

0.10.12

Patch Changes

0.10.11

Patch Changes

0.10.10

Patch Changes

0.10.9

Patch Changes

0.10.8

Patch Changes

0.10.7

Patch Changes

0.10.6

Patch Changes

0.10.5

Patch Changes

0.10.4

Patch Changes

0.10.3

Patch Changes

0.10.2

Patch Changes

0.10.1

Patch Changes

0.10.0

Minor Changes

Patch Changes

0.9.14

Patch Changes

0.9.13

Patch Changes

0.9.12

Patch Changes

0.9.11

Patch Changes

0.9.10

Patch Changes

0.9.9

Patch Changes

0.9.8

Patch Changes

0.9.7

Patch Changes

0.9.6

Patch Changes

0.9.5

Patch Changes

0.9.4

Patch Changes

0.9.3

Patch Changes

0.9.2

Patch Changes

0.9.1

Patch Changes

0.9.0

Minor Changes

  • #10604 135e066 Thanks @penalosa! - Enable Remote Bindings without the need for the remoteBindings: true property

Patch Changes

0.8.71

Patch Changes

0.8.70

Patch Changes

0.8.69

Patch Changes

0.8.68

Patch Changes

0.8.67

Patch Changes

0.8.66

Patch Changes

0.8.65

Patch Changes

0.8.64

Patch Changes

0.8.63

Patch Changes

0.8.62

Patch Changes

0.8.61

Patch Changes

0.8.60

Patch Changes

0.8.59

Patch Changes

0.8.58

Patch Changes

0.8.57

Patch Changes

0.8.56

Patch Changes

0.8.55

Patch Changes

0.8.54

Patch Changes

0.8.53

Patch Changes

0.8.52

Patch Changes

0.8.51

Patch Changes

0.8.50

Patch Changes

0.8.49

Patch Changes

0.8.48

Patch Changes

  • #9533 0a5bb5a Thanks @petebacondarwin! - fix: ensure that the sourcemap-codec library has been transformed correctly to be imported in workerd during Vitest runs

    Prior to this the inline snapshot tests were failing because they use the magic-string library, which in turn relies upon the sourcemap-codec library.

    This resulted in errors that look like:

    Error running worker: SyntaxError: The requested module '@jridgewell/sourcemap-codec' does not provide an export named 'encode'
    

0.8.47

Patch Changes

0.8.46

Patch Changes

0.8.45

Patch Changes

0.8.44

Patch Changes

0.8.43

Patch Changes

0.8.42

Patch Changes

0.8.41

Patch Changes

0.8.40

Patch Changes

0.8.39

Patch Changes

0.8.38

Patch Changes

0.8.37

Patch Changes

0.8.36

Patch Changes

0.8.35

Patch Changes

0.8.34

Patch Changes

0.8.33

Patch Changes

0.8.32

Patch Changes

0.8.31

Patch Changes

0.8.30

Patch Changes

0.8.29

Patch Changes

0.8.28

Patch Changes

0.8.27

Patch Changes

0.8.26

Patch Changes

0.8.25

Patch Changes

0.8.24

Patch Changes

0.8.23

Patch Changes

0.8.22

Patch Changes

0.8.21

Patch Changes

0.8.20

Patch Changes

0.8.19

Patch Changes

0.8.18

Patch Changes

0.8.17

Patch Changes

0.8.16

Patch Changes

0.8.15

Patch Changes

0.8.14

Patch Changes

0.8.13

Patch Changes

0.8.12

Patch Changes

0.8.11

Patch Changes

0.8.10

Patch Changes

0.8.9

Patch Changes

0.8.8

Patch Changes

  • #8624 665ebd8 Thanks @emily-shen! - fix: Add usage charge warning when Vectorize and AI bindings are used in Vitest

    Vectorize and AI bindings can now be used with Vitest. However, because they have no local simulators, they will access your account and incur usage charges, even in testing. Therefore we recommend mocking any usage of these bindings when testing.

  • Updated dependencies [ecbab5d, 24c2c8f]:

    • wrangler@4.6.0

0.8.7

Patch Changes

0.8.6

Patch Changes

0.8.5

Patch Changes

0.8.4

Patch Changes

0.8.3

Patch Changes

0.8.2

Patch Changes

0.8.1

Patch Changes

0.8.0

Minor Changes

  • #7334 869ec7b Thanks @threepointone! - chore: update esbuild

    This patch updates esbuild from 0.17.19 to 0.24.2. That's a big bump! Lots has gone into esbuild since May '23. All the details are available at https://github.com/evanw/esbuild/blob/main/CHANGELOG.md / https://github.com/evanw/esbuild/blob/main/CHANGELOG-2023.md.

    • We now support all modern JavasScript/TypeScript features suported by esbuild (as of December 2024). New additions include standard decorators, auto-accessors, and the using syntax.

    • 0.18 introduced wider support for configuration specified via tsconfig.json https://github.com/evanw/esbuild/issues/3019. After observing the (lack of) any actual broken code over the last year for this release, we feel comfortable releasing this without considering it a breaking change.

    • 0.19.3 introduced support for import attributes

      import stuff from './stuff.json' with { type: 'json' }
      

      While we don't currently expose the esbuild configuration for developers to add their own plugins to customise how modules with import attributes are bundled, we may introduce new "types" ourselves in the future.

    • 0.19.0 introduced support for wildcard imports. Specifics here (https://github.com/evanw/esbuild/blob/main/CHANGELOG-2023.md#0190). tl;dr -

      • These 2 patterns will bundle all files that match the glob pattern into a single file.

        const json1 = await import("./data/" + kind + ".json");
        
        const json2 = await import(`./data/${kind}.json`);
        
      • This pattern will NOT bundle any matching patterns:

        const path = "./data/" + kind + ".js";
        const json2 = await import(path);
        

        You can use find_additional_modules to bundle any additional modules that are not referenced in the code but are required by the project.

      Now, this MAY be a breaking change for some. Specifically, if you were previously using the pattern (that will now include all files matching the glob pattern in the bundle), BUT find_additional_modules was NOT configured to include some files, those files would now be included in the bundle. For example, consider this code:

      // src/index.js
      export default {
        async fetch() {
          const url = new URL(request.url);
          const name = url.pathname;
          const value = (await import("." + name)).default;
          return new Response(value);
        },
      };
      

      Imagine if in that folder, you had these 3 files:

      // src/one.js
      export default "one";
      
      // src/two.js
      export default "two";
      
      // src/hidden/secret.js
      export default "do not share this secret";
      

      And your wrangler.toml was:

      name = "my-worker"
      main = "src/index.js
      

      Before this update:

      1. A request to anything but http://localhost:8787/ would error. For example, a request to http://localhost:8787/one.js would error with No such module "one.js".
      2. Let's configure wrangler.toml to include all .js files in the src folder:
      name = "my-worker"
      main = "src/index.js
      
      find_additional_modules = true
      rules = [
        { type = "ESModule", globs = ["*.js"]}
      ]
      

      Now, a request to http://localhost:8787/one.js would return the contents of src/one.js, but a request to http://localhost:8787/hidden/secret.js would error with No such module "hidden/secret.js". To include this file, you could expand the rules array to be:

      rules = [
        { type = "ESModule", globs = ["**/*.js"]}
      ]
      

      Then, a request to http://localhost:8787/hidden/secret.js will return the contents of src/hidden/secret.js.

      After this update:

      • Let's put the wrangler.toml back to its original configuration:
      name = "my-worker"
      main = "src/index.js
      
      • Now, a request to http://localhost:8787/one.js will return the contents of src/one.js, but a request to http://localhost:8787/hidden/secret.js will ALSO return the contents of src/hidden/secret.js. THIS MAY NOT BE WHAT YOU WANT. You can "fix" this in 2 ways:

        1. Remove the inline wildcard import:
        // src/index.js
        export default {
          async fetch() {
            const name = new URL(request.url).pathname;
            const moduleName = "./" + name;
            const value = (await import(moduleName)).default;
            return new Response(value);
          },
        };
        

        Now, no extra modules are included in the bundle, and a request to http://localhost:8787/hidden/secret.js will throw an error. You can use the find_additional_modules feature to include it again. 2. Don't use the wildcard import pattern:

        // src/index.js
        import one from "./one.js";
        import two from "./two.js";
        
        export default {
          async fetch() {
            const name = new URL(request.url).pathname;
            switch (name) {
              case "/one.js":
                return new Response(one);
              case "/two.js":
                return new Response(two);
              default:
                return new Response("Not found", { status: 404 });
            }
          },
        };
        

        Further, there may be some files that aren't modules (js/ts/wasm/text/binary/etc) that are in the folder being included (For example, a photo.jpg file). This pattern will now attempt to include them in the bundle, and throw an error. It will look like this:

        [ERROR] No loader is configured for ".png" files: src/photo.jpg

        To fix this, simply move the offending file to a different folder.

        In general, we DO NOT recommend using the wildcard import pattern. If done wrong, it can leak files into your bundle that you don't want, or make your worker slightly slower to start. If you must use it (either with a wildcard import pattern or with find_additional_modules) you must be diligent to check that your worker is working as expected and that you are not leaking files into your bundle that you don't want. You can configure eslint to disallow dynamic imports like this:

        // eslint.config.js
        export default [
          {
            rules: {
              "no-restricted-syntax": [
                "error",
                {
                  selector: "ImportExpression[argument.type!='Literal']",
                  message:
                    "Dynamic imports with non-literal arguments are not allowed.",
                },
              ],
            },
          },
        ];
        

Patch Changes

0.7.8

Patch Changes

0.7.7

Patch Changes

0.7.6

Patch Changes

  • #8338 2d40989 Thanks @GregBrimble! - feat: Upload _headers and _redirects if present with Workers Assets as part of wrangler deploy and wrangler versions upload.

  • #8288 cf14e17 Thanks @CarmenPopoviciu! - feat: Add assets Proxy Worker skeleton in miniflare

    This commit implements a very basic Proxy Worker skeleton, and wires it in the "pipeline" miniflare creates for assets. This Worker will be incrementally worked on, but for now, the current implementation will forward all incoming requests to the Router Worker, thus leaving the current assets behaviour in local dev, the same.

    This is an experimental feature available under the --x-assets-rpc flag: wrangler dev --x-assets-rpc.

  • Updated dependencies [2d40989, da568e5, cf14e17, af9a57a, fbba583, bca1fb5, 79c7810]:

0.7.5

Patch Changes

0.7.4

Patch Changes

0.7.3

Patch Changes

0.7.2

Patch Changes

0.7.1

Patch Changes

0.7.0

Minor Changes

  • #7923 aaa9cca Thanks @penalosa! - Support Vitest v3. While this drops testing for Vitest v2, we expect Vitest v2 will continue to work as well.

Patch Changes

0.6.16

Patch Changes

0.6.15

Patch Changes

0.6.14

Patch Changes

  • #7810 ac4f30b Thanks @edmundhung! - Added Vite dependency pre-bundling support. If you encounter module resolution issues—such as: Error: Cannot use require() to import an ES Module or Error: No such module—you can now bundle these dependencies using the deps.optimizer option:

    import { defineWorkersConfig } from "@cloudflare/vitest-pool-workers/config";
    
    export default defineWorkersConfig({
      test: {
        deps: {
          optimizer: {
            ssr: {
              enabled: true,
              include: ["your-package-name"],
            },
          },
        },
        poolOptions: {
          workers: {
            // ...
          },
        },
      },
    });
    

    Fixed #6591, #6581, #6405.

  • Updated dependencies [a025ad2]:

0.6.13

Patch Changes

0.6.12

Patch Changes

0.6.11

Patch Changes

0.6.10

Patch Changes

0.6.9

Patch Changes

0.6.8

Patch Changes

0.6.7

Patch Changes

0.6.6

Patch Changes

0.6.5

Patch Changes

0.6.4

Patch Changes

0.6.3

Patch Changes

0.6.2

Patch Changes

0.6.1

Patch Changes

0.6.0

Minor Changes

Patch Changes

0.5.41

Patch Changes

0.5.40

Patch Changes

0.5.39

Patch Changes

0.5.38

Patch Changes

0.5.37

Patch Changes

0.5.36

Patch Changes

0.5.35

Patch Changes

0.5.34

Patch Changes

0.5.33

Patch Changes

0.5.32

Patch Changes

0.5.31

Patch Changes

0.5.30

Patch Changes

0.5.29

Patch Changes

0.5.28

Patch Changes

0.5.27

Patch Changes

0.5.26

Patch Changes

0.5.25

Patch Changes

0.5.24

Patch Changes

0.5.23

Patch Changes

0.5.22

Patch Changes

0.5.21

Patch Changes

0.5.20

Patch Changes

0.5.19

Patch Changes

0.5.18

Patch Changes

0.5.17

Patch Changes

0.5.16

Patch Changes

0.5.15

Patch Changes

  • #6835 5c50949 Thanks @emily-shen! - feature: enable asset routing in the vitest integration for Workers + static assets

    Integration tests (using the SELF binding) in Workers + assets projects will now return static assets if present on that path. Previously all requests went to the user worker regardless of whether static assets would have been served in production.

    Unit style tests intentionally do not return static assets.

  • Updated dependencies [d696850, 5c50949, dc92af2, 82180a7, 54924a4, 30b7328]:

0.5.14

Patch Changes

0.5.13

Patch Changes

0.5.12

Patch Changes

0.5.11

Patch Changes

0.5.10

Patch Changes

0.5.9

Patch Changes

0.5.8

Patch Changes

0.5.7

Patch Changes

0.5.6

Patch Changes

0.5.5

Patch Changes

0.5.4

Patch Changes

0.5.3

Patch Changes

0.5.2

Patch Changes

0.5.1

Patch Changes

0.5.0

Minor Changes

Patch Changes

0.4.31

Patch Changes

0.4.30

Patch Changes

0.4.29

Patch Changes

0.4.28

Patch Changes

0.4.27

Patch Changes

0.4.26

Patch Changes

0.4.25

Patch Changes

0.4.24

Patch Changes

0.4.23

Patch Changes

0.4.22

Patch Changes

0.4.21

Patch Changes

  • #6455 b4483dd Thanks @petebacondarwin! - fix: ensure that directory imports in commonjs modules get resolved to their index file

    Fixes #6406

0.4.20

Patch Changes

0.4.19

Patch Changes

0.4.18

Patch Changes

0.4.17

Patch Changes

0.4.16

Patch Changes

0.4.15

Patch Changes

0.4.14

Patch Changes

0.4.13

Patch Changes

0.4.12

Patch Changes

0.4.11

Patch Changes

0.4.10

Patch Changes

0.4.9

Patch Changes

0.4.8

Patch Changes

0.4.7

Patch Changes

0.4.6

Patch Changes

  • #6050 a0c3327 Thanks @threepointone! - chore: Normalize more deps

    This is the last of the patches that normalize dependencies across the codebase. In this batch: ws, vitest, zod , rimraf, @types/rimraf, ava, source-map, glob, cookie, @types/cookie, @microsoft/api-extractor, @types/mime, @types/yargs, devtools-protocol, @vitest/ui, execa, strip-ansi

    This patch also sorts dependencies in every package.json

  • #6029 f5ad1d3 Thanks @threepointone! - chore: Normalize some dependencies in workers-sdk

    This is the first of a few expected patches that normalize dependency versions, This normalizes undici, concurrently, @types/node, react, react-dom, @types/react, @types/react-dom, eslint, typescript. There are no functional code changes (but there are a couple of typecheck fixes).

  • #6079 2e531b4 Thanks @CarmenPopoviciu! - fix: define defineWorkersConfig using overload signatures

    The type definition of defineWorkersConfig doesn't work with mergeConfig of vitest/config because of type mismatch. This function should be an overload function like defineConfig

  • Updated dependencies [dc597a3, 15aff8f, b4c0233, a0c3327, f5ad1d3, c643a81, 31cd51f, db66101, 374bc44, 267761b, 84e6aeb]:

0.4.5

Patch Changes

0.4.4

Patch Changes

0.4.3

Patch Changes

0.4.2

Patch Changes

0.4.1

Patch Changes

0.4.0

Minor Changes

Patch Changes

0.3.0

Minor Changes

Patch Changes

0.2.12

Patch Changes

0.2.11

Patch Changes

0.2.10

Patch Changes

0.2.9

Patch Changes

  • #5458 f520a71 Thanks @Cherry! - fix: loosen the peer dependency version on vitest to support versions ranging from 1.3.0 to 1.5.0

  • Updated dependencies []:

0.2.8

Patch Changes

0.2.7

Patch Changes

0.2.6

Patch Changes

0.2.5

Patch Changes

0.2.4

Patch Changes

0.2.3

Patch Changes

0.2.2

Patch Changes

0.2.1

Patch Changes

0.2.0

Minor Changes

  • #5612 8f470d9 Thanks @Skye-31! - Feat: Support specifying an environment for your worker when running tests. This allows your tests to pick up bindings & variables that are scoped to specific environments.

    For example:

    import { defineWorkersConfig } from "@cloudflare/vitest-pool-workers/config";
    
    export default defineWorkersConfig({
      test: {
        poolOptions: {
          workers: {
            wrangler: {
              configPath: "./wrangler.toml",
              environment: "production",
            },
          },
        },
      },
    });
    

Patch Changes

  • #5589 92bc055 Thanks @Skye-31! - fix: Support importing ES modules from libraries that do not correctly provide "type"="module" not use .mjs extensions

    The toucan-js library has an entry point of "module": "dist/index.esm.js". This file does not use the standard .mjs extension, nor does it specify "type"="module", so the resolution and loading algorithm fails to identify this file as an ES Module, defaulting to CommonJS, breaking Vitest. Fixes #5588

  • Updated dependencies [9a46e03, c9f081a, fbe1c9c, 22f5841, c9f081a]:

0.1.19

Patch Changes

0.1.18

Patch Changes

0.1.17

Patch Changes

0.1.16

Patch Changes

0.1.15

Patch Changes

0.1.14

Patch Changes

0.1.13

Patch Changes

0.1.12

Patch Changes

0.1.11

Patch Changes

0.1.10

Patch Changes

0.1.9

Patch Changes

0.1.8

Patch Changes

0.1.7

Patch Changes

0.1.6

Patch Changes

0.1.5

Patch Changes

0.1.4

Patch Changes

0.1.3

Patch Changes

0.1.2

Patch Changes

0.1.1

Patch Changes

0.1.0

Minor Changes

  • #5241 ca891e7 Thanks @mrbbot! - feature: implement Workers Vitest integration

    Introducing the new Workers Vitest integration! The @cloudflare/vitest-pool-workers package allows you to write unit and integration tests using Vitest that run inside the Workers runtime. Refer to the documentation and examples for more information.

Patch Changes