Skip to content

fix: destructured test members and a framework version in a nested package - #71

Merged
Huldoser merged 2 commits into
mainfrom
task/ti-48
Oct 31, 2026
Merged

Huldoser merged 2 commits into
mainfrom
task/ti-48

Conversation

@Huldoser

Copy link
Copy Markdown
Owner

What changed

Two false notLoaded results found while scanning a year of public projects with 0.6.1. Each fix has a test that failed first.

Names destructured from a test object (Playwright and Vitest). const { describe, beforeEach } = test made every such name read as test itself: beforeEach(...) became a test without a body (test-without-body, every test of the file notLoaded), and describe(...) became one test that hid the tests inside it. Each name is now read as its member, also nested (const { describe: { serial } } = test) and through the rest of an object. Checked against the runners: Playwright 1.64.1 binds every member of test; in Vitest 3.2, 4.1 and 5.0, hooks, describe and the modifiers work destructured, while each, for, skipIf, runIf and extend read this and throw, and their calls aren't read.

Framework version in a nested package. When the root and the folders above it have no version, the scan now reads the shallowest package.json below the root that declares the framework and holds scanned files, with its lockfile or installed copy first. Storybook declares Vitest only in code/package.json, so the version was null, Vitest 5's rules applied, and a file with vi.mock in a block was refused, though Storybook ran Vitest 3.2.4.

Rescans, 0.6.1 against this branch:

Commit 0.6.1 This branch
payloadcms/payload 39a9df9b (Oct 30), Playwright 511 tests, 44 notLoaded 1670 tests, 0 notLoaded
storybookjs/storybook 0133ff2e9 (Nov 2, 2025), Vitest version null, 3476 tests, 71 notLoaded version 3.2.4, 3467 tests, 0 notLoaded

Payload's jump comes from 73 spec files that destructure describe from test. Storybook's 9 fewer tests are in code/presets/react-webpack, which no project of its vitest.workspace.ts runs; Vitest 3 reads that file, Vitest 4 dropped it.

Left for later: a version per config for monorepos that mix versions (needs a new output field), and reporting the Vitest members that throw when destructured.

Checklist

  • Tests cover the change, and npm run coverage reports 100%.
  • The docs describe the change: the guide or reference pages, the README, or the TSDoc of exported functions.
  • No docs change is needed.
  • A changeset describes the change for users (npm run changeset), or the change does not affect them.

`const { beforeEach } = test` made every call through `beforeEach` read as
`test(...)`, as the alias lookup took the whole value the variable was
destructured from. Payload's e2e files do this: their hooks became tests
without a body, so whole files were reported as not loaded, and their
describes became single tests that hid the tests inside.

Playwright binds every member of `test`, so all of them work destructured.
In Vitest, `each`, `for`, `skipIf`, `runIf` and `extend` read `this` and
throw when destructured (checked on Vitest 3.2.4, 4.1.12 and 5.0.5); their
calls are never read through a variable, so they need no special case.

Chose: read the member from the destructuring pattern in alias(); over
binding destructured names in the bindings classes, which only know names
bound to Playwright or Vitest itself and not to local aliases.
Storybook declares Vitest only in `code/package.json` and locks it in
`code/yarn.lock`; the root and the folders above it have nothing. The scan
gave a null version, applied Vitest 5's rules, and refused a file that
calls `vi.mock` in a block, though Storybook ran Vitest 3.2.4.

When the root and above have no version, the shallowest package.json
below the root that declares the framework and holds scanned files is read
the same way, from its folder up: installed copy, lockfile, then the
declaration. The files are found before the version now, which needs no
version to find them.

Chose: one version per scan from the shallowest declaring package that
holds scanned files; over a version per config or test file, which would
be exact for monorepos that mix versions but needs a new field in the
output format (TI-56).
@Huldoser
Huldoser enabled auto-merge (squash) October 31, 2026 01:53
@Huldoser
Huldoser merged commit bf8383f into main Oct 31, 2026
31 checks passed
@Huldoser
Huldoser deleted the task/ti-48 branch October 31, 2026 01:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant