fix: fix suite hook throwing errors for unused auto test-scoped fixture#10035
Conversation
✅ Deploy Preview for vitest-dev ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
packages/runner/src/fixture.ts
Outdated
| for (const fixture of registrations.values()) { | ||
| if (fixture.auto || usedProps.has(fixture.name)) { | ||
| // suite hook shouldn't automatically trigger unused test-scoped fixtures | ||
| const auto = fixture.auto && !(options?.suiteHook && fixture.scope === 'test') |
There was a problem hiding this comment.
Can we make the check simpler? fixture.auto && !(options?.suiteHook && fixture.scope === 'test') is vile
There was a problem hiding this comment.
I also argued so hard with Codex 🤣
I thought of some options and ended up with what I have now.
fixture.auto && !(options?.suiteHook && fixture.scope === 'test')fixture.auto && (!options?.suiteHook || fixture.scope !== 'test')fixture.auto && (options?.suiteHook ? fixture.scope !== 'test' : true)options?.suiteHook ? (fixture.auto && fixture.scope !== 'test') : fixture.auto
I might prefer the last one actually.
packages/runner/src/fixture.ts
Outdated
| for (const fixture of registrations.values()) { | ||
| if (fixture.auto || usedProps.has(fixture.name)) { | ||
| // suite hook shouldn't automatically trigger unused test-scoped fixtures | ||
| const auto = fixture.auto && !(options?.suiteHook && fixture.scope === 'test') |
There was a problem hiding this comment.
Yes or no 👀
| const auto = fixture.auto && !(options?.suiteHook && fixture.scope === 'test') | |
| const auto = options?.suiteHook ? (fixture.auto && fixture.scope !== 'test') : fixture.auto |
There was a problem hiding this comment.
@AriPerkkio help us
I think we should do a multi line check
if(!fixture.auto) return false
const isSuiteScope = !!options?.suiteHook
return suiteScope ? fixture.scope !== 'test' : fixture.scope === 'test'Something like this
There was a problem hiding this comment.
fixture.auto && !(options?.suiteHook && fixture.scope === 'test')
😱
I would probably write this into a fully verbose function.
function isAuto(fixture, options) {
if (!fixture.auto) {
return false;
}
if (options.suiteHook && fixture.scope === "test") {
return false;
}
return true;
}There was a problem hiding this comment.
Switched to isAutoFixture 🚘
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Description
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
pnpm-lock.yamlunless you introduce a new test example.Tests
pnpm test:ci.Documentation
pnpm run docscommand.Changesets
feat:,fix:,perf:,docs:, orchore:.