Skip to content

[vitest-plugin] Resolve the runner's vitest/worker import from the plugin - #17108

Merged
petebacondarwin merged 1 commit into
cloudflare:mainfrom
Hebilicious:vitest-plugin-resolve-vitest-worker-from-plugin
Nov 23, 2026
Merged

petebacondarwin merged 1 commit into
cloudflare:mainfrom
Hebilicious:vitest-plugin-resolve-vitest-worker-from-plugin

Conversation

@Hebilicious

@Hebilicious Hebilicious commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #17107.

The runner is the virtual module /index.mjs. The module fallback service resolved its vitest/worker import with Vite, with /index.mjs as the importer. That file does not exist, so Vite resolved from the project root. When the root could not resolve vitest, no test ran. When a parent directory had another vitest, the runner loaded that version.

This change resolves vitest/worker from the plugin package, in both the legacy and the new module registry fallback. The pool's own vitest imports resolve from the same place, so the runner uses the same Vitest as the pool.

Reproduction: https://github.com/Hebilicious/vitest-plugin-worker-resolve-repro


  • 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 is a bug fix with no change to configuration.

Note

This is a contribution from an AI agent: Claude Code, Claude Opus 5.5.


Devin Review

@changeset-bot

changeset-bot Bot commented Nov 21, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 4a5b900

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 Patch

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-actions

Copy link
Copy Markdown
Contributor

Hi @Hebilicious. Thanks for taking the time to contribute to Workers SDK.

This PR has been automatically closed because you are not currently a registered (vouched) collaborator for this repository.

AI tools now let our team generate proposed code changes quickly. Reviewing changes, checking that they solve the right problem, and maintaining code quality over time still take substantial care and effort. We therefore limit PRs to registered collaborators so we can focus that effort where it is most useful.

For the majority of external contributors, the most effective way to help is through issues: describing a problem or use case, providing a minimal reproduction, investigating its cause, or helping us verify a fix. Those contributions help us understand what needs to change and are very welcome.

We will take an initial look at this PR and decide whether it is something we want to invest time in reviewing and maintaining. We may reopen it if we decide to proceed, but we cannot guarantee that it will be reopened or receive a full review.

@github-actions github-actions Bot closed this Nov 21, 2026
@github-project-automation github-project-automation Bot moved this from Untriaged to Done in workers-sdk Nov 21, 2026
@workers-devprod
workers-devprod requested review from a team and petebacondarwin and removed request for a team November 21, 2026 14:55
@workers-devprod

workers-devprod commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • ✅ @cloudflare/wrangler
Show detailed file reviewers

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Devin Review found 2 potential issues.

Devin Review

@github-project-automation github-project-automation Bot moved this from Done to Untriaged in workers-sdk Nov 22, 2026
@clanky-the-clanker

Copy link
Copy Markdown
Contributor

This pull request was not reviewed automatically because its author does not have write access to this repository. A maintainer with write access can start a review by commenting clanky review (or clanker review or @clanky-the-clanker review), optionally followed by instructions (e.g. clanky review focus on the retry logic).

@pkg-pr-new

pkg-pr-new Bot commented Nov 22, 2026

Copy link
Copy Markdown
@cloudflare/autoconfig

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

@cloudflare/build-output-utils

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

@cloudflare/codemods

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

@cloudflare/config

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

@cloudflare/containers-shared

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

create-cloudflare

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

@cloudflare/deploy-helpers

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

@cloudflare/kv-asset-handler

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

miniflare

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

@cloudflare/pages-functions

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

@cloudflare/pages-shared

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

@cloudflare/runtime-types

npm i https://pkg.pr.new/@cloudflare/runtime-types@17108

@cloudflare/unenv-preset

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

@cloudflare/vite-plugin

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

@cloudflare/vitest-plugin

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

@cloudflare/workers-auth

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

@cloudflare/workers-editor-shared

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

@cloudflare/workers-utils

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

wrangler

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

commit: 4a5b900

@petebacondarwin
petebacondarwin enabled auto-merge (squash) November 23, 2026 15:58

@workers-devprod workers-devprod left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Codeowners reviews satisfied

@petebacondarwin
petebacondarwin merged commit 65f6f33 into cloudflare:main Nov 23, 2026
168 of 170 checks passed
@github-project-automation github-project-automation Bot moved this from Untriaged to Approved in workers-sdk Nov 23, 2026
@github-project-automation github-project-automation Bot moved this from Approved to Done in workers-sdk Nov 23, 2026
brandhaug added a commit to brandhaug/b2b-saas-starter that referenced this pull request Nov 27, 2026
## pnpm-workspace.yaml (default)

## Dependency Updates

| Package | From | To | Type |
| --- | --- | --- | --- |
| `@cloudflare/vitest-plugin` | 1.9.0 | 1.9.2 | patch |
| `@cloudflare/workers-types` | 5.20261123.1 | 5.20261124.1 | minor |
| `miniflare` | 5.20261119.0-beta | 5.20261123.1-beta | minor |
| `wrangler` | 4.166.0 | 4.168.0 | minor |

## Release Notes

<details>
<summary><b>@<!---->cloudflare/vitest-plugin</b> (1.9.0 → 1.9.2) — 2
releases</summary>

<details>
<summary><b>1.9.2</b></summary>

### Patch Changes

- Updated dependencies
[[`3d228ba`](cloudflare/workers-sdk@3d228ba)]:
  - miniflare@5.20261123.1-beta

</details>

<details>
<summary><b>1.9.1</b></summary>

### Patch Changes

- [#17070](cloudflare/workers-sdk#17070)
[`657179d`](cloudflare/workers-sdk@657179d)
Thanks [@<!---->dependabot](https://github.com/apps/dependabot)! -
Update `DEFAULT_COMPAT_DATE` to 2026-11-23

Use the bundled workerd release's compatibility date by default when
scaffolding new projects or when no compatibility date is configured.

- [#16879](cloudflare/workers-sdk#16879)
[`5970e6a`](cloudflare/workers-sdk@5970e6a)
Thanks [@<!---->edmundhung](https://github.com/edmundhung)! - Throw from
`readD1Migrations()` when the migrations directory doesn't exist

Passing options with a missing `migrationsDir` used to return no
migrations, so a typo silently applied nothing. It now throws "No
migrations present at …", as Wrangler does. Passing a directory path
that doesn't exist throws the same error. A migrations directory that
can't be read now also throws when you pass options, and both forms name
the directory in the error.

- [#17108](cloudflare/workers-sdk#17108)
[`65f6f33`](cloudflare/workers-sdk@65f6f33)
Thanks [@<!---->Hebilicious](https://github.com/Hebilicious)! - Resolve
the runner's `vitest/worker` import from the plugin, not from the
project root

The runner is a virtual module, `/index.mjs`, so Vite resolved its
`vitest/worker` import from the project root. When the root could not
resolve `vitest`, as in a pnpm workspace whose root package does not
depend on it, no test file ran and Workers threw `No such module
"vitest/worker"`. When a parent directory had another `vitest` version,
the runner loaded that version and Vitest failed to find the runner. The
plugin now resolves `vitest/worker` from its own package, so the runner
uses the same Vitest as the pool.

- Updated dependencies [[`657179d`](https://github.com/

…[full
notes](https://github.com/cloudflare/workers-sdk/releases/tag/%40cloudflare/vitest-plugin%401.9.1)

</details>

</details>

<details>
<summary><b>miniflare</b> (5.20261119.0-beta → 5.20261123.1-beta) — 2
releases</summary>

<details>
<summary><b>5.20261123.1-beta</b></summary>

### Minor Changes

- [#17133](cloudflare/workers-sdk#17133)
[`3d228ba`](cloudflare/workers-sdk@3d228ba)
Thanks [@<!---->edmundhung](https://github.com/edmundhung)! - List
Durable Object IDs by the class the Worker exports

`listDurableObjectIds()` now takes the Durable Object class and the
Worker that exports it, as in `mf.listDurableObjectIds("Counter",
"my-worker")`. This is a breaking change in v5 beta: a binding name now
throws `No Durable Object class named …`, unless the Worker also exports
a class with that name, in which case that class's IDs are listed.

</details>

<details>
<summary><b>5.20261123.0-beta</b></summary>

### Minor Changes

- [#17129](cloudflare/workers-sdk#17129)
[`5b45f32`](cloudflare/workers-sdk@5b45f32)
Thanks [@<!---->edmundhung](https://github.com/edmundhung)! - Support
`captions.get()` and `customerCode` in the local Stream binding

The local Stream binding now implements the Stream fields added in
`@cloudflare/workers-types`. `captions.get(language)` returns the stored
WebVTT file for an uploaded caption. Generated captions have no content
in local mode, so they return an empty WebVTT file, and a missing
caption throws `NotFoundError` as the API does. Videos also include
`customerCode`, set to `"placeholder"` to match the placeholder
subdomain in local playback URLs.

- [#17024](cloudflare/workers-sdk#17024)
[`00413bb`](cloudflare/workers-sdk@00413bb)
Thanks [@<!---->edmundhung](https://github.com/edmundhung)! - Start even
when a binding refers to a Worker that isn't running

A service, Durable Object or Workflow binding to a Worker that isn't
running now always fails only when it's used, and events sent to a tail
consumer that isn't running are dropped. Before, Miniflare failed to
start when the dev registry was disabled, as it is in the Vitest plugin.

### Patch Changes

- [#17070](cloudflare/workers-sdk#17070)
[`657179d`](cloudflare/workers-sdk@657179d)
Thanks [@<!---->dependabot](https://github.com/apps/dependabot)! -
Update `DEFAULT_COMPAT_DATE` to 2026-11-23

Use the bundled workerd release's compatibility date by default when
scaffolding new projects or when no compatibility date is configured.

- [#17070](cloudflare/workers-sdk#17070)
[`657179d`](cloudflare/workers-sdk@657179d)
Thanks [@<!---->dependabot](https://github.com/apps/dependabot)! - Upd

…[full
notes](https://github.com/cloudflare/workers-sdk/releases/tag/miniflare%405.20261123.0-beta)

</details>

</details>

<details>
<summary><b>wrangler</b> (4.166.0 → 4.168.0) — 2 releases</summary>

<details>
<summary><b>4.168.0</b></summary>

### Minor Changes

- [#16680](cloudflare/workers-sdk#16680)
[`96e936c`](cloudflare/workers-sdk@96e936c)
Thanks [@<!---->mglewis](https://github.com/mglewis)! - Apply
`images.url_transformations` when deploying a Worker

`wrangler deploy` and `wrangler versions deploy` now apply the
`images.url_transformations` setting to the deployed Worker. The setting
is applied after the Worker and its triggers have been deployed. If it
can't be applied, the command fails with the reason from the API.
Removing `url_transformations` from the configuration leaves the
Worker's existing setting in place.

The setting isn't applied for `--dry-run`, `wrangler versions upload`,
or Workers deployed to a dispatch namespace.

### Patch Changes

- [#17063](cloudflare/workers-sdk#17063)
[`6c45ad7`](cloudflare/workers-sdk@6c45ad7)
Thanks
[@<!---->sidharthachatterjee](https://github.com/sidharthachatterjee)! -
Request the billing scopes when logging in with cf and Wrangler

Include `billing:write` in the default OAuth scopes of cf and Wrangler
so they can create account subscriptions, which is how products such as
R2 are enabled on an account. cf also requests `billing:read`. Existing
OAuth sessions need a new login to request the scopes.

- [#16947](cloudflare/workers-sdk#16947)
[`de6b171`](cloudflare/workers-sdk@de6b171)
Thanks [@<!---->umeraamir69](https://github.com/umeraamir69)! - Fix
`WRANGLER_LOG_PATH` being ignored when set in `vite.config.ts` after a
static import of `@cloudflare/vite-plugin`

The debug log filepath is now resolved lazily on first write (memoized),
matching how `WRANGLER_WRITE_LOGS` is read. Setting
`process.env.WRANGLER_LOG_PATH` in the Vite config body after importing
the plugin now writes logs to the configured path instead of the gl

…[full
notes](https://github.com/cloudflare/workers-sdk/releases/tag/wrangler%404.168.0)

</details>

<details>
<summary><b>4.167.0</b></summary>

### Minor Changes

- [#17060](cloudflare/workers-sdk#17060)
[`fa50aba`](cloudflare/workers-sdk@fa50aba)
Thanks [@<!---->petebacondarwin](https://github.com/petebacondarwin)! -
Support `--env-file` in the experimental `cf-wrangler dev` delegate

Wrangler-bundled projects can now use `cf dev -- --env-file ../../.env`
to load a shared development file outside the project directory without
enabling `CLOUDFLARE_INCLUDE_PROCESS_ENV`. Repeat `--env-file` to load
multiple files, with later files overriding earlier values.

- [#17093](cloudflare/workers-sdk#17093)
[`310633d`](cloudflare/workers-sdk@310633d)
Thanks [@<!---->for-the-kidz](https://github.com/for-the-kidz)! - Remove
the `wrangler dispatch-namespace rename` command

Renaming a Workers for Platforms dispatch namespace left the namespace
name stored in dispatcher bindings out of date, which could make Workers
in the namespace impossible to read or delete by name. The Cloudflare
API now rejects requests that change a dispatch namespace's name, so the
command has been removed. To use a different name, create a new dispatch
namespace and redeploy your Workers to it.

### Patch Changes

- [#17102](cloudflare/workers-sdk#17102)
[`1e65920`](cloudflare/workers-sdk@1e65920)
Thanks [@<!---->samarthyadavv](https://github.com/samarthyadavv)! - Exit
with a nonzero status when the Basin SQL service rejects a query

`wrangler basin sql query` reports the service error and exits with
status 1 so shell scripts and CI can detect a rejected query.

- [#17099](cloudflare/workers-sdk#17099)
[`fc3d770`](cloudflare/workers-sdk@fc3d770)
Thanks [@<!---->mayanthacreates](https://github.com/mayanthacreates)! -
Show that `--local` is the

…[full
notes](https://github.com/cloudflare/workers-sdk/releases/tag/wrangler%404.167.0)

</details>

</details>

---
*This PR was auto-generated by
[catalog-update-action](https://github.com/brandhaug/catalog-update-action).*

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

🐛 BUG: vitest-plugin resolves vitest/worker from the project root, so no test runs when the root cannot resolve vitest

3 participants