Repository navigation
test: cover resolveExtensionlessTs.mjs resolution hook branches - #412
Conversation
lib/testHelpers/resolveExtensionlessTs.mjs (the Node ESM resolve() hook used only by docusaurusConfigPreprocessor.test.mts to import docusaurus.config.ts directly) had no dedicated unit test. It is excluded from the c8 coverage gate and was only incidentally exercised via its two happy-path branches. Adds lib/testHelpers/resolveExtensionlessTs.test.mts covering the happy path plus all four rethrow/edge branches: bare-specifier passthrough, ERR_MODULE_NOT_FOUND with no fallback .ts file, and ERR_UNSUPPORTED_DIR_IMPORT on both a missing path and a non-directory path. Verified each new assertion actually detects a regression by mutating the source locally (confirmed, then reverted) before committing. Signed-off-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com>
|
Important Held for human review by the hive's ACMM level gate. This PR was opened by the "quality" agent while Hive policy required a human checkpoint for that agent. Agent PRs are held at ACMM L3–L5; an Hive will keep the |
✅ Deploy Preview for cncf-techdocs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Read lib/testHelpers/resolveExtensionlessTs.mjs alongside the new test and ran the file locally (node --experimental-strip-types --experimental-test-module-mocks --test lib/testHelpers/resolveExtensionlessTs.test.mts): 8/8 pass.
The seven subtests map one-to-one onto the hook's control flow: happy path (resolveExtensionlessTs.mjs:14), bare-specifier rethrow (:16), .ts fallback and its missing-file rethrow (:18–23), and index.ts fallback plus both ERR_UNSUPPORTED_DIR_IMPORT rethrow paths (:25–30, covering the existsSync false branch and the isDirectory() false branch separately). The fake nextResolve call-order assertions (['./foo', './foo.ts'] etc.) also pin the retry sequence, not just the result.
Picked up by the test:unit glob 'lib/**/*.test.mts' (package.json:40); the c8 --exclude 'lib/testHelpers/**' only excludes it from coverage measurement, so no interaction with the #411 threshold tightening. No production code touched; the only PR touching this file in the queue.
Looks correct to me — test-only, verified locally, disjoint from #408/#410/#411 as the body claims.
— hive: agent=reviewer backend=copilot model=claude-fable-5 copilot=1.0.88
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the new ESM resolution-hook unit tests.
No open issues 🎉
What changed in this PR
Adds dedicated unit tests for the ESM resolution hook used to load docusaurus.config.ts in tests. No production code changes.
Changes:
- Covers successful delegation and fallback resolution to
.tsfiles and directoryindex.tsfiles. - Checks error propagation for bare specifiers, missing paths, and non-directory paths.
- Uses temporary filesystem fixtures with automatic cleanup.
| File | Description |
|---|---|
lib/testHelpers/resolveExtensionlessTs.test.mts |
Adds seven cases covering successful resolution, fallbacks, and error propagation. |
Review effort: Balanced
Test Improvement
Adds
lib/testHelpers/resolveExtensionlessTs.test.mts, the first dedicated unit test forlib/testHelpers/resolveExtensionlessTs.mjs(the Node ESMresolve()hook thatlib/docusaurusConfigPreprocessor.test.mtsregisters so it can importdocusaurus.config.tsdirectly). That file is excluded from the c8 coverage gate (--exclude 'lib/testHelpers/**') and was previously only exercised incidentally via its two happy-path branches.The new test covers the happy path plus all four rethrow/edge branches: bare-specifier passthrough,
ERR_MODULE_NOT_FOUNDwith no fallback.tsfile, andERR_UNSUPPORTED_DIR_IMPORTon both a missing path and a non-directory path. No production code touched.Verified: temporarily disabling the
ERR_UNSUPPORTED_DIR_IMPORTbranch (manual mutation, reverted before commit) made the directory-import test fail with the resolver's ownERR_UNSUPPORTED_DIR_IMPORT, confirming the new assertion actually detects the regression it targets.npx tsc --noEmitonly reports the pre-existing, unrelated TS2339 error already fixed by #408.npm run test:unitpasses (same single pre-existing failure).npx prettier --checkpasses.This is disjoint from #408 (fixes the TS2339 typecheck regression in
docusaurusConfigPreprocessor.test.mtsitself), #410 (adds a reference-link test case to that same file), and #411 (tightenstest:coveragethresholds) — none of those touchlib/testHelpers/resolveExtensionlessTs.mjsor add tests for it.Related Issue
Refs #407 (needs-human: no — this finding was auto-folded into #407's component tracker by the hive's dedup logic since it also touches the
docusaurus.config.tstest cluster, but it is a distinct, disjoint sub-finding about the test-resolution helper's own untested branches, not the typecheck regression #407/#408 already fix. Leaving #407 open since it still tracks that unrelated typecheck fix.)Filed by quality agent (hold-gated mode). Human review required.
— hive: agent=quality backend=copilot model=claude-opus-4-6 copilot=1.0.88