Skip to content

[vitest-plugin] Support Container tests - #15695

Draft
ghostwriternr wants to merge 2 commits into
naresh/vitest-clean-failed-runtimesfrom
naresh/vitest-container-support
Draft

ghostwriternr wants to merge 2 commits into
naresh/vitest-clean-failed-runtimesfrom
naresh/vitest-container-support

Conversation

@ghostwriternr

@ghostwriternr ghostwriternr commented Sep 17, 2026

Copy link
Copy Markdown
Member

@cloudflare/vitest-plugin currently disables Containers, so a Worker that uses ctx.container cannot be tested in the Workers Vitest pool.

Prepare default and named images from the Worker configuration Wrangler and Vite already use. Cloudflare-managed registry images remain unsupported.

Image preparation is cached across watch reruns, and Dockerfile or build-context changes rebuild the affected images. Runtime containers remain workerd-owned and are removed through managed Miniflare disposal. A run-scoped Docker acceptance test verifies both application and proxy-sidecar removal by exact ID. Projects that set dev.enable_containers to false stay Docker-independent.


  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: This feature will be included in the broader documentation update for the new Containers runtime before release.

@changeset-bot

changeset-bot Bot commented Sep 17, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f44bcda

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@cloudflare/vitest-plugin Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-project-automation github-project-automation Bot moved this to Untriaged in workers-sdk Sep 17, 2026
@ghostwriternr
ghostwriternr marked this pull request as ready for review September 17, 2026 14:42
@workers-devprod
workers-devprod requested review from a team and tpmmorris and removed request for a team September 17, 2026 14:43
@workers-devprod

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • @cloudflare/wrangler
Show detailed file reviewers
  • .changeset/fresh-containers-vitest.md: [@cloudflare/wrangler]
  • fixtures/vitest-plugin-examples/container-app/Dockerfile: [@cloudflare/wrangler]
  • fixtures/vitest-plugin-examples/container-app/README.md: [@cloudflare/wrangler]
  • fixtures/vitest-plugin-examples/container-app/container/simple-node-app.js: [@cloudflare/wrangler]
  • fixtures/vitest-plugin-examples/container-app/src/env.d.ts: [@cloudflare/wrangler]
  • fixtures/vitest-plugin-examples/container-app/src/index.ts: [@cloudflare/wrangler]
  • fixtures/vitest-plugin-examples/container-app/src/tsconfig.json: [@cloudflare/wrangler]
  • fixtures/vitest-plugin-examples/container-app/test/container-disabled.test.ts: [@cloudflare/wrangler]
  • fixtures/vitest-plugin-examples/container-app/test/container.test.ts: [@cloudflare/wrangler]
  • fixtures/vitest-plugin-examples/container-app/test/container.unit.test.ts: [@cloudflare/wrangler]
  • fixtures/vitest-plugin-examples/container-app/tsconfig.json: [@cloudflare/wrangler]
  • fixtures/vitest-plugin-examples/container-app/vitest.config.ts: [@cloudflare/wrangler]
  • fixtures/vitest-plugin-examples/container-app/vitest.disabled.config.ts: [@cloudflare/wrangler]
  • fixtures/vitest-plugin-examples/container-app/wrangler.disabled.jsonc: [@cloudflare/wrangler]
  • fixtures/vitest-plugin-examples/container-app/wrangler.jsonc: [@cloudflare/wrangler]
  • fixtures/vitest-plugin-examples/package.json: [@cloudflare/wrangler]
  • fixtures/vitest-plugin-examples/vitest.config.ts: [@cloudflare/wrangler]
  • packages/vitest-plugin/README.md: [@cloudflare/wrangler]
  • packages/vitest-plugin/package.json: [@cloudflare/wrangler]
  • packages/vitest-plugin/src/pool/cloudflare-pool-worker.ts: [@cloudflare/wrangler]
  • packages/vitest-plugin/src/pool/config.ts: [@cloudflare/wrangler]
  • packages/vitest-plugin/src/pool/containers.ts: [@cloudflare/wrangler]
  • packages/vitest-plugin/src/pool/index.ts: [@cloudflare/wrangler]
  • packages/vitest-plugin/src/pool/plugin.ts: [@cloudflare/wrangler]
  • packages/vitest-plugin/test/containers.test.ts: [@cloudflare/wrangler]
  • pnpm-lock.yaml: [@cloudflare/wrangler]

@pkg-pr-new

pkg-pr-new Bot commented Sep 17, 2026

Copy link
Copy Markdown
@cloudflare/autoconfig

npm i https://pkg.pr.new/@cloudflare/autoconfig@15695

@cloudflare/build-output-utils

npm i https://pkg.pr.new/@cloudflare/build-output-utils@15695

@cloudflare/codemods

npm i https://pkg.pr.new/@cloudflare/codemods@15695

@cloudflare/config

npm i https://pkg.pr.new/@cloudflare/config@15695

@cloudflare/containers-shared

npm i https://pkg.pr.new/@cloudflare/containers-shared@15695

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@15695

@cloudflare/deploy-helpers

npm i https://pkg.pr.new/@cloudflare/deploy-helpers@15695

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@15695

miniflare

npm i https://pkg.pr.new/miniflare@15695

@cloudflare/pages-functions

npm i https://pkg.pr.new/@cloudflare/pages-functions@15695

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@15695

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@15695

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@15695

@cloudflare/vitest-plugin

npm i https://pkg.pr.new/@cloudflare/vitest-plugin@15695

@cloudflare/workers-auth

npm i https://pkg.pr.new/@cloudflare/workers-auth@15695

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@15695

@cloudflare/workers-utils

npm i https://pkg.pr.new/@cloudflare/workers-utils@15695

wrangler

npm i https://pkg.pr.new/wrangler@15695

commit: f44bcda

devin-ai-integration[bot]

This comment was marked as resolved.

ask-bonk[bot]

This comment was marked as resolved.

@ask-bonk

ask-bonk Bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

I'm Bonk, and I've done a quick review of your PR.

Adds Vitest support for container-backed Durable Objects.

  1. P1: Watch-mode config restarts permanently disable containers. One inline suggestion posted.

github run

"*/vitest.*config.*ts",
// Hosted non-Linux runners do not provide the Docker engine required by
// the enabled Container project. The disabled project still runs there.
...(isCINonLinux ? ["!container-app/vitest.config.ts"] : []),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should we also exclude container testing for all native windows as this will always fail if CI is not set and might cause some confusion? Similar to durable objects below

@ghostwriternr
ghostwriternr force-pushed the naresh/vitest-container-support branch from 0d15630 to 86c9a62 Compare September 21, 2026 17:23
@ghostwriternr
ghostwriternr changed the base branch from main to naresh/vitest-clean-failed-runtimes September 21, 2026 17:23
@ghostwriternr
ghostwriternr added this pull request to stack #15757 September 21, 2026 17:23
Prepare Container images from normalized Worker configuration so tests
can use the real ctx.container runtime interface.

Cache prepared images across overlapping pool workers, cancel unfinished
builds during shutdown, and resume after Vitest configuration restarts.
A throwing runner-socket close must not skip managed Miniflare disposal.

Cover Durable Object-managed named images and scheduler-backed default
images in one fixture. Cloudflare-managed registry images remain
unsupported.
Container image preparation is cached between watch runs. Invalidate
that cache when local Docker inputs change so reruns cannot use stale
images.
@ghostwriternr
ghostwriternr force-pushed the naresh/vitest-container-support branch from 86c9a62 to f44bcda Compare September 22, 2026 00:20
@ghostwriternr
ghostwriternr marked this pull request as draft September 22, 2026 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Untriaged

Development

Successfully merging this pull request may close these issues.

3 participants