Skip to content

fix: follow what Vue and Svelte components import, and give three slow tests 20 s - #68

Merged
Huldoser merged 3 commits into
mainfrom
component-imports
Oct 29, 2026
Merged

Huldoser merged 3 commits into
mainfrom
component-imports

Conversation

@Huldoser

Copy link
Copy Markdown
Owner

Two fixes from the board, one commit each.

Components in dependencyHash (TI-29). A .vue or .svelte file was hashed by its text only, so a change to a child component or a helper it imports didn't change the hash of the tests that mount it. In watchlist-vue, Watchlist.vue imports WatchlistRow.vue, which was missing from the Watchlist tests' dependencies. A component's <script> blocks are now parsed as one module, with the rest of the file blanked so offsets stay the file's, and every import in them is followed: names only the template uses, and type imports, as Vue builds the props of defineProps<Props>() from the types. The file itself still counts once, by its text, so tests whose components import nothing keep their hash. A script that doesn't parse keeps the text and marks the test. Vue's <script src> isn't followed; the limits page says so. Changeset: patch.

Timeouts on the macOS Intel runner (TI-18). The schema test runs the TypeScript compiler and takes about 4.3 s of its 5 s there on passing runs; it failed at 9.9 s on Oct 27, together with the bin test (6.2 s). The 10,000-helper test takes 4.9 s. On one core shared with 12 busy loops the schema test timed out locally too. These three tests now have 20 s, as test-inventory-mcp's stdio tests do; the 5 s default stays for the rest.

Checked: npm test (984 passed), npm run coverage (100%), lint, typecheck, format; the docs build.

A .vue or .svelte file was hashed by its text only, so a change to a child
component or a helper it imports didn't change the hash of the tests that
mount it (TI-29: Watchlist.vue imports WatchlistRow.vue in watchlist-vue).

The component's <script> blocks are now parsed as one module, with the
rest of the file blanked so offsets stay the file's, and every import in
them is followed, also names only the template uses, and type imports
too, as Vue builds the props of defineProps<Props>() from the types. The file itself still
counts once, by its text. A script that doesn't parse keeps the text and
marks the test.

Chose: follow every import of a component's scripts; reading templates to
narrow it down needs a Vue and a Svelte template parser, both new
dependencies, for little gain.
Chose: leave Vue's <script src> out and list it in the limits page; it is
rare, and following it means a second module per component.
The schema test runs the TypeScript compiler, and took 4,318 ms of its
5,000 ms on the passing macOS Intel run of Oct 29; it failed at 9,919 ms on
Oct 27, with the bin test, whose first import of the command line took
6,201 ms. The 10,000-helper test in playwright.test.ts took 4,862 ms. On one
core shared with 12 busy loops, the schema test timed out locally at
5,730 ms (TI-18).

Chose: a 20 s timeout on these three tests, as test-inventory-mcp's stdio
tests have; a longer default for every test would hide a test that becomes
slow, and moving the schema check out of the suite would weaken it.
Comment thread src/dependency-hash.ts Fixed
CodeQL (js/bad-tag-filter) flagged that the script block pattern missed an
end tag such as `</script lang="ts">`, which HTML still reads as the end of
the script. The scan then missed the component's imports. A comment that
ends with `--!>` wasn't seen as ended either, so a `<script>` inside it was
followed as code.

Chose: `</script` followed by a space, `/` or `>`, rather than the alert's
suggested `<\/script(?:\s|[^>])*>`, which also matches `</scripts>`.
@Huldoser
Huldoser enabled auto-merge (squash) October 29, 2026 22:07
@Huldoser
Huldoser merged commit fa9b97a into main Oct 29, 2026
31 checks passed
@Huldoser
Huldoser deleted the component-imports branch October 29, 2026 22:09
@Huldoser Huldoser mentioned this pull request Oct 30, 2026
2 of 4 tasks
Huldoser added a commit that referenced this pull request Oct 30, 2026
## What changed

Release 0.6.1, made with `npm run release`.

### Patch Changes

- [#69](#69)
[`41ce74d`](41ce74d)
- An import that matches a tsconfig `paths` pattern but none of its
files, as an installed package does with
`"paths": { "*": ["./src/types/*"] }`, now goes on to the usual lookup,
as TypeScript does. Such imports were reported
as unreadable, so every test that used a package or a built-in module
such as `node:fs` got
`hasUnfollowedDependencies`. An `@/` or `~/` alias whose files are
missing is still reported.

- [#69](#69)
[`41ce74d`](41ce74d)
- A file that only passes names on, as a barrel `index.ts` with `export
* from './fees'` or
`export { OrderTicket } from './order-ticket'` does, is now in the
`dependencies` of the tests that import through it,
so `--related` keeps them when the file changes. Which module a
re-export points at is now part of `dependencyHash`, as
an import's already was, so the hash of a test that imports through a
re-export changes once.

- [#69](#69)
[`41ce74d`](41ce74d)
- An imported file that isn't text, such as `import logo from
'./logo.png'`, is now taken by its bytes in
`dependencyHash`. It was read as text, where every byte that isn't UTF-8
reads the same, so two different images could
  give the same hash.

- [#69](#69)
[`41ce74d`](41ce74d)
- A `<script>` block in a Vue or Svelte component whose `type` isn't
JavaScript, such as
`<script type="application/ld+json">` in `<svelte:head>`, is no longer
read as the component's code. It made the
component unreadable, so the modules its real script imports were
missing from `dependencies`.

- [#68](#68)
[`fa9b97a`](fa9b97a)
- `dependencyHash` now follows what a Vue or Svelte single-file
component imports, also the components and helpers only
its template uses, so a change to a child component changes the hash of
the tests that mount its parent. A component
whose script doesn't parse is still taken by its text, and its tests get
`hasUnfollowedDependencies`.

- [#69](#69)
[`41ce74d`](41ce74d)
- A file with brackets nested more than 500 deep, such as a generated
fixture, now gets a `parse-error` instead of
crashing the scan. oxc-parser overflows the native stack on such a file,
about 5,000 deep, and the process dies with a
segmentation fault that no error handling can catch, so no inventory was
written.

- [#69](#69)
[`41ce74d`](41ce74d)
- `expectCount` now counts `expect.element()`, the assertion of Vitest
browser mode, so a browser test that checks the
page only with `await expect.element(locator).toBeVisible()` no longer
looks like a test without assertions.

- [#69](#69)
[`41ce74d`](41ce74d)
- An import written with a `.jsx` extension now finds the `.tsx` file it
refers to, as `.js` already found `.ts`, so
`import { OrderHeader } from './OrderHeader.jsx'` is followed instead of
marking the test with
  `hasUnfollowedDependencies`.

- [#69](#69)
[`41ce74d`](41ce74d)
- From Playwright 1.57, the config's `tag` is now read: every test gets
it first in its `tags`, and a project's `grep` or
`grepInvert` matches it, so a project with `grepInvert: /@nightly/` in a
config with `tag: '@nightly'` no longer runs
the tests. When the scan can't work out the `tag`, as for
`process.env.CI_ENVIRONMENT_NAME`, it gets a
`config-value-unknown` warning, and the tests of a project with a `grep`
get `projects: null`.

- [#69](#69)
[`41ce74d`](41ce74d)
- From Playwright 1.64, a project with `default: false` is no longer
listed in a test's `projects`, as Playwright runs it
only with `--project`, unless a project that runs lists it in
`dependencies` or `teardown`. A `default` the scan can't
work out gets a `config-value-unknown` warning, and the tests it may run
get `projects: null`.

- [#69](#69)
[`41ce74d`](41ce74d)
- Playwright's `defineConfig(base, config)` is now merged as Playwright
merges it: a project of `config` merges into the
project of `base` with the same name instead of replacing all of
`base`'s projects, and `expect`, `use` and `build`
merge key by key. A setup project from a base config is no longer lost,
and an `expect.toHaveScreenshot.pathTemplate`
from the base still marks the tests that compare screenshots with
`hasUnfollowedDependencies`.

- [#69](#69)
[`41ce74d`](41ce74d)
- A Vitest `retry` object in a test's or describe's options before
Vitest 4.1 now gets an `unresolved-option` warning
and `retries: null`. Vitest 4.0 and 3.2 never run such a test; the scan
used to ignore the object and give the
  config's retry count instead.

- [#69](#69)
[`41ce74d`](41ce74d)
- A Vitest test's own `skip`, `only`, `todo` or `fails` option now
replaces the one its tags set, as Vitest does, so
`test('title', { tags: ['flaky'], skip: false }, fn)` is active instead
of skipped, and a conditional `skip` replaces
  the tag's unconditional one.

- [#69](#69)
[`41ce74d`](41ce74d)
- An import that starts with `@/` or `~/`, as a Vite `resolve.alias`
allows, now gives the test
`hasUnfollowedDependencies` and a `dependency-not-followed` warning when
no tsconfig `paths` define it. It was taken for
an installed package, so the aliased file was missing from
`dependencies` without a sign, and `--related` left the test
  out when that file changed.

- [#69](#69)
[`41ce74d`](41ce74d)
- Vitest 5 tests follow the option rules of Vitest 5.0.5: the last of
`.skip`, `skipIf()` and `runIf()` on a test
decides its skip, so `test.skip.skipIf(false)` is active, and a
`skipIf()` or `runIf()` replaces the skip of a tag or of
the options a describe passes down. An option set to `undefined`, as in
`test.skip('title', { skip: undefined }, fn)`,
  no longer undoes the chain or a tag.

- [#69](#69)
[`41ce74d`](41ce74d)
- In Vitest 5, the projects of a config that another config lists in
`projects` are named inside that config's name, as
Vitest names them: the `unit` project of `apps/web/vitest.config.ts`,
named `web`, is `web (unit)`.

- [#69](#69)
[`41ce74d`](41ce74d)
- A Vitest project without a `test.name` now has the name Vitest gives
it, in `projects` and in `configs`: the `name` in
the package.json of its folder, else the folder's name, so `projects:
['packages/*']` names its projects
`@trading/pricing` or `ledger` instead of `""`. An inline project
without a name is named after its place among the
inline projects, as `0`, and in Vitest 5 no longer takes the name of the
config it extends.

## 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.
- [x] No docs change is needed.
- [x] A changeset describes the change for users (`npm run changeset`),
or the change does not affect them.
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.

2 participants