Repository navigation
Inline the plugin's own modules so its setup file hooks into the vitest running the tests, fixing "Vitest failed to find the current suite" under pnpm workspaces with two vitest copies - #19
Conversation
…with the vitest running the tests, not a second copy resolved from node_modules Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
|
|

Bug fix + tests — a project whose
vitestdiffers from the one@useblacksmith/vitest@0.5.0resolves beside itself innode_modulesno longer fails every test file withVitest failed to find the current suite. Nothing changes for a project where the two resolve to the same copy.Problem
0.5.0's setup file
record-reads.jsdoesimport { afterAll } from 'vitest'(#12). Vitest externalizes modules undernode_modules, so Node resolves thatvitestfrom the plugin's directory. In a pnpm workspace where two packages depend on the plugin with different peer sets (different@types/nodemajors was enough), pnpm keeps one@useblacksmith/vitest@0.5.0(vitest@5.1.0)instance whosevitestsymlink points at one package's copy. The other package's tests then call a second vitest instance'safterAll, outside any suite, and every test file fails before it runs:0.4.0's setup file imported nothing from
vitest, so it was unaffected.--pool=forksdoes not help;server.deps.inline: [/@useblacksmith\/vitest/]in the consumer's config does.Fix
The plugin's
config()hook adds its own package totest.server.deps.inline, so Vite transformsrecord-reads.jsand resolves itsvitestimport the same way it does for the test files: to the copy running them.inlineAllguards a consumer withinline: true, where merging a list would produce[true, '@useblacksmith/vitest'].Evidence
New test
installed under node_modulescopiesdist/andpackage.jsoninto the fixture'snode_modules/@useblacksmith/vitest, places a second copy ofvitestunder it, and loads the plugin as'@useblacksmith/vitest'. Without the fix it fails with the error above (15 of 16 test files not recorded); with it the full run passes and a changed fixture reruns only its test, so reads are still recorded through the inlined setup file.Risks
record-reads.js, itsvitestimport) once per worker instead of Node loading them natively; they are small and have no other dependencies.server.deps.inlinegets ours appended by Vite's config merge; one who setsinline: trueis left alone.Link to Devin session: https://app.devin.ai/sessions/908e16d5e5d54e2c968498f368f535d8
Open in Devin Desktop: https://app.devin.ai/desktop/session/908e16d5e5d54e2c968498f368f535d8?variant=devin
Requested by: @max-blacksmith
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need. (Staging)Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.🟢 Devin Review found nothing to fix · View findings