Skip to content

test: cover resolveExtensionlessTs.mjs resolution hook branches - #412

Merged
nate-double-u merged 4 commits into
mainfrom
quality/test-resolve-extensionless-ts
Nov 16, 2026
Merged

nate-double-u merged 4 commits into
mainfrom
quality/test-resolve-extensionless-ts

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Test Improvement

Adds lib/testHelpers/resolveExtensionlessTs.test.mts, the first dedicated unit test for lib/testHelpers/resolveExtensionlessTs.mjs (the Node ESM resolve() hook that lib/docusaurusConfigPreprocessor.test.mts registers so it can import docusaurus.config.ts directly). 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_FOUND with no fallback .ts file, and ERR_UNSUPPORTED_DIR_IMPORT on both a missing path and a non-directory path. No production code touched.

Verified: temporarily disabling the ERR_UNSUPPORTED_DIR_IMPORT branch (manual mutation, reverted before commit) made the directory-import test fail with the resolver's own ERR_UNSUPPORTED_DIR_IMPORT, confirming the new assertion actually detects the regression it targets. npx tsc --noEmit only reports the pre-existing, unrelated TS2339 error already fixed by #408. npm run test:unit passes (same single pre-existing failure). npx prettier --check passes.

This is disjoint from #408 (fixes the TS2339 typecheck regression in docusaurusConfigPreprocessor.test.mts itself), #410 (adds a reference-link test case to that same file), and #411 (tightens test:coverage thresholds) — none of those touch lib/testHelpers/resolveExtensionlessTs.mjs or 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.ts test 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

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>
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

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 outreach PR that targets a repository this hive does not manage is held at every level because it publishes project-facing communication into someone else's project.

Hive will keep the hold label until a human removes it. Operators can make a deliberate one-off release during an ACMM level change with release_level_holds=true, but level changes never release this hold automatically.

@netlify

netlify Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for cncf-techdocs ready!

Name Link
🔨 Latest commit 3dba35b
🔍 Latest deploy log https://app.netlify.com/projects/cncf-techdocs/deploys/6afb8ec09c9735ad17b025fd
😎 Deploy Preview https://deploy-preview-412--cncf-techdocs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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 .ts files and directory index.ts files.
  • 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

@nate-double-u
nate-double-u merged commit 90eb119 into main Nov 16, 2026
9 checks passed
@nate-double-u
nate-double-u deleted the quality/test-resolve-extensionless-ts branch November 16, 2026 23:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants