Skip to content

[FEATURE] Replace manual Cloudflare test mocks with Cloudflare Workers Vitest integration #1209

@314systems

Description

@314systems

Is your feature request related to a problem?

Tests that involve Cloudflare-specific runtime behavior currently require manually assembled mocks for bindings, execution context, and other Workers APIs.

These mocks can become complex and may diverge from the real Cloudflare Workers runtime. This makes tests harder to maintain and creates a risk that bugs are introduced by the mocks themselves rather than by the application code.

Describe the solution you'd like

I would like to see the test setup use the official Cloudflare Workers Vitest integration where possible.

In particular, tests could use @cloudflare/vitest-pool-workers with cloudflareTest, and Cloudflare-provided test APIs such as:

  • env from cloudflare:workers
  • createExecutionContext from cloudflare:test
  • runInDurableObject from cloudflare:test
  • exports.default.fetch where appropriate

This would help reduce custom mocking, make tests closer to the actual Workers runtime, and lower the chance of mock-specific bugs.

Describe alternatives you've considered

Alternative 1: Continue maintaining manual mocks for Cloudflare bindings and runtime APIs.

@opennextjs/cloudflare version

1.19.1

Additional context

https://developers.cloudflare.com/durable-objects/examples/testing-with-durable-objects/
https://developers.cloudflare.com/workers/testing/vitest-integration/write-your-first-test/

Before submitting

  • I have checked that there isn't already a similar feature request
  • This is a single feature (not multiple features in one request)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions