#7795 Issue with testing workers using SELF
User configuration error, not bug. Reporter using literal object config instead of defineWorkersConfig(). Aug 2025 comment identified fix. Reproduction repo shows same incorrect pattern.
Close as configuration error with explanation of correct pattern
Analysis Report
Issue Review: cloudflare/workers-sdk#7795
Summary
SELF import from cloudflare:test fails with "Failed to load url cloudflare:test" error.
Findings
- Created: 2025-01-16
- Updated: 2025-10-30
- Version: wrangler 3.101.0, @cloudflare/vitest-pool-workers 0.6.0 -> 4.60.0 / 0.12.6
- Component: vitest-pool-workers
- Labels: bug, vitest
- Comments: 4
Key Evidence
- Reproduction repo provided: https://github.com/valeriydev/self-issue
- Maintainer @penalosa requested reproduction (Jan 2025)
- User provided reproduction repo (Jan 2025)
- Another user linked to potentially related #6214 (Feb 2025)
- CRITICAL: @njdancer (Aug 2025) identified root cause as USER ERROR
- Reporter was defining vitest config as literal object instead of using
defineWorkersConfig() - The linked reproduction repo also contains this incorrect pattern
- Using
defineWorkersConfig()function correctly resolves the issue
- Reporter was defining vitest config as literal object instead of using
Recommendation
Status: CLOSE
Reasoning: This is not a bug but a user configuration error. The reporter and reproduction repo both use an incorrect pattern (defining vitest config as a literal object) instead of the correct pattern (using defineWorkersConfig() from @cloudflare/vitest-pool-workers/config). @njdancer confirmed that using the correct configuration pattern resolves the issue.
Action: Close as configuration error. The documentation at https://developers.cloudflare.com/workers/testing/vitest-integration/configuration/ clearly shows the correct usage.
Suggested Comment
Closing this issue as it appears to be a configuration error rather than a bug.
As @njdancer identified, the issue is that the vitest config is defined as a literal object instead of using the
defineWorkersConfig()function:Incorrect:
export default { test: { poolOptions: { workers: { ... } } } };Correct:
import { defineWorkersConfig } from "@cloudflare/vitest-pool-workers/config"; export default defineWorkersConfig({ test: { poolOptions: { workers: { ... } } } });The
defineWorkersConfig()function is required to properly set up the cloudflare:test module resolution. See the configuration documentation.If you're still experiencing issues after using the correct configuration pattern, please open a new issue with an updated reproduction.
Notes & Feedback (0)
No notes yet.