tallneil
## What happens `packages/ts-document`'s test suite cannot start. On `main` at `48561e0`: ``` $ pnpm --filter @reactuses/ts-document test FAIL __test__/index.test.ts ● Test suite failed to run TypeError: Cannot read properties of undefined (reading 'testEnvironmentOptions') at new NodeEnvironment (node_modules/.pnpm/[email protected]/.../build/index.js:88:49) at TestScheduler.scheduleTests (node_modules/.pnpm/@[email protected]_.../build/TestScheduler.js:333:13) Tests: 0 total ``` Zero tests run. This is not new — it is the state of `main`. ## Why Three problems stacked on top of each other. Each one hides the next, so fixing only the first looks like it failed. **1. `jest-environment-node` is never declared.** `packages/ts-document` pins jest 27 (`jest ^27.0.6`, `ts-jest ^27.0.3`) and its `jest.config.js` sets `testEnvironment: 'node'`, which jest resolves *by name* at runtime. The package does not list `jest-environment-node`, so resolution falls through to pnpm's hoisted store. Both versions are present: ``` node_modules/.pnpm/[email protected] node_modules/.pnpm/[email protected] ``` but `node_modules/.pnpm/node_modules/jest-environment-node` is **29.7.0**, pulled in by `packages/core` (on jest 29). So jest-core 27.5.1 loads a v29 environment and constructs it with the v27 signature. Hence the `TypeError`. **2. `@types/node` is `^15.14.9`.** With the environment fixed, the next failure is `TS2307: Cannot find module 'node:path'` on `__test__/index.test.ts:1`. Node 15 types predate `node:`-prefixed specifiers. **3. The snapshots are stale.** With both fixed, the suite finally runs — and 7 tests fail on snapshot mismatches, e.g. ``` - "type": "[InnerProps](#InnerProps)", + "type": "[InnerProps](#innerprops)", ``` plus a dropped `title` tag. These trace to `902a86f feat: i18n (#177)`, which changed `defaultLinkFormatter` to lowercase anchors and rewrote tag collection to be locale-aware (`tagsByBaseName`, `lang === 'zh'`). That commit touched three files under `src/` and zero under `__test__/`. The source is right; the snapshots were never re-recorded, because the runner could not run to say so. ## Why nothing caught it - `.github/workflows/ci.yml` runs lint, the core tests, and a core build. It never invokes this suite. - `.github/dependabot.yml` watches only `/packages/core`, and ignores `version-update:semver-major` for all dependencies. It also cannot bump a dependency that was never declared. ## Impact `prepublishOnly` for this package is `npm run test && npm run tsc`, so **publishing `@reactuses/ts-document` would fail today.** It also means the package behind `gend` has no working verification. `packages/core/scripts/tsdoc.ts` calls `generateMarkdown()` once per locale (`en`, `zh`, `zh-Hant`) to produce the `%%API%%` tables on the docs site — exactly the locale-aware code path `902a86f` rewrote and left untested. ## Fix Verified locally on `48561e0`. In `packages/ts-document/package.json`: - add `"jest-environment-node": "^27.5.1"` so the environment matches jest-core - raise `@types/node` off v15 (I tested `^22`; `^16` is likely the actual floor) then re-record the snapshots. Result: ``` Test Suites: 1 passed, 1 total Tests: 13 passed, 13 total Snapshots: 17 updated, 2 passed, 19 total ``` The snapshot file changes by `+48/-91` — the net deletion matches i18n collapsing per-locale tag variants onto a base name. Worth a maintainer eye to confirm that is the intended output before it is committed, since re-recording bakes in whatever the current behavior is. Optional: `ts-jest ^27` declares peer `typescript >=3.8 <5.0` while this package pins `typescript: 5.4.5`, so every install warns. With the above fixed, all 13 tests pass regardless — it appears cosmetic, but aligning it would quiet the install. ## Note on re-syncing instead `packages/ts-document` is vendored from [`PengJiyuan/ts-document`](https://github.com/PengJiyuan/ts-document) (migrated in `a4af357`). Pulling fresh from upstream is not an option: it was last pushed 2023-03-17, is still at 0.8.0 — the same version vendored here — and carries the same stale pins (`@types/node ^15.12.5`, `jest ^27.0.6`, `ts-jest ^27.0.3`). It also has none of the i18n work. The stale deps were inherited at migration, not introduced here, so repairing in place looks like the only path. Happy to open a PR if the approach looks right. --- Investigation done with Claude Code; every result above was reproduced locally rather than inferred.