Skip to content

Vitest Integration mishandles ASSETS binding and prioritizes wrangler.jsonc over vitest.config.ts #9130

@resYuto

Description

@resYuto

Which Cloudflare product(s) does this pertain to?

Workers Vitest Integration

What versions & operating system are you using?

wrangler 4.14.1, @cloudflare/vitest-pool-workers 0.8.24, Node 22.15.0 macOS 15.4.1

Please provide a link to a minimal reproduction

https://github.com/resYuto/vitest-error-minimal

Describe the Bug

Even if the ASSETS binding is defined in vitest.config.ts, the test runner will fail to start if the folder specified in wrangler.jsonc cannot be found.

Reproduction:

  1. Clone reproduction repo.
  2. pnpm i
  3. pnpm run test -- make sure directory .output/public not exists.

Please provide any relevant error logs

part of wrangler.jsonc

  "assets": {
    "binding": "ASSETS",
    "directory": "./.output/public/"
  },

part of vitest.config.ts

        miniflare: {
          assets: {
            directory: "./public",
          },

Error log:

Error: The directory specified by the "assets.directory" field in your configuration file does not exist:
[PROJECT ROOT]/.output/public
 ❯ getAssetsOptions node_modules/.pnpm/wrangler@4.14.1/node_modules/wrangler/wrangler-dist/cli.js:153148:11
 ❯ Module.unstable_getMiniflareWorkerOptions node_modules/.pnpm/wrangler@4.14.1/node_modules/wrangler/wrangler-dist/cli.js:156622:33
 ❯ parseCustomPoolOptions node_modules/.pnpm/@cloudflare+vitest-pool-workers@0.8.24_@vitest+runner@3.1.2_@vitest+snapshot@3.1.2_vite_251b46cc8263e9419486ca12fd938f8d/node_modules/@cloudflare/vitest-pool-workers/dist/pool/index.mjs:345:71
 ❯ parseProjectOptions node_modules/.pnpm/@cloudflare+vitest-pool-workers@0.8.24_@vitest+runner@3.1.2_@vitest+snapshot@3.1.2_vite_251b46cc8263e9419486ca12fd938f8d/node_modules/@cloudflare/vitest-pool-workers/dist/pool/index.mjs:407:12
 ❯ executeMethod node_modules/.pnpm/@cloudflare+vitest-pool-workers@0.8.24_@vitest+runner@3.1.2_@vitest+snapshot@3.1.2_vite_251b46cc8263e9419486ca12fd938f8d/node_modules/@cloudflare/vitest-pool-workers/dist/pool/index.mjs:1673:18
 ❯ Object.runTests node_modules/.pnpm/@cloudflare+vitest-pool-workers@0.8.24_@vitest+runner@3.1.2_@vitest+snapshot@3.1.2_vite_251b46cc8263e9419486ca12fd938f8d/node_modules/@cloudflare/vitest-pool-workers/dist/pool/index.mjs:1788:7
 ❯ executeTests node_modules/.pnpm/vitest@3.1.2_@types+debug@4.1.12_@types+node@22.15.3_happy-dom@17.4.6_jiti@2.4.2_lightn_05df7f66327e2ec93a795230325ce848/node_modules/vitest/dist/chunks/coverage.BUdIvXbr.js:7710:3
 ❯ node_modules/.pnpm/vitest@3.1.2_@types+debug@4.1.12_@types+node@22.15.3_happy-dom@17.4.6_jiti@2.4.2_lightn_05df7f66327e2ec93a795230325ce848/node_modules/vitest/dist/chunks/cli-api.z029PxYZ.js:9240:6
 ❯ Vitest.runFiles node_modules/.pnpm/vitest@3.1.2_@types+debug@4.1.12_@types+node@22.15.3_happy-dom@17.4.6_jiti@2.4.2_lightn_05df7f66327e2ec93a795230325ce848/node_modules/vitest/dist/chunks/cli-api.z029PxYZ.js:9267:10

Serialized Error: { telemetryMessage: 'The assets directory specified does not exist' }

Metadata

Metadata

Assignees

No one assigned

    Labels

    vitestRelating to the Workers Vitest integration

    Type

    No fields configured for Bug.

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions