Skip to content

[quality] test: unit coverage for scripts/lib/load-tsx.js loadTsxModule — new scripts/lib/load-tsx.test.js - #1271

Open
kubestellar-hive[bot] wants to merge 1 commit into
mainfrom
quality/test-load-tsx-loader
Open

kubestellar-hive[bot] wants to merge 1 commit into
mainfrom
quality/test-load-tsx-loader

Conversation

@kubestellar-hive

Copy link
Copy Markdown
Contributor

Test Improvement

Adds scripts/lib/load-tsx.test.js — 12 node:test cases for scripts/lib/load-tsx.js (loadTsxModule), which had no test importing it.

Exact ground claimed by this PR: file scripts/lib/load-tsx.test.js (new), function loadTsxModule in scripts/lib/load-tsx.js. No production file is touched; no other file is modified.

load-tsx.js is shared test infrastructure: scripts/countme-analytics-charts.test.js, scripts/image-churn-charts.test.js and scripts/report-chart.test.js all load real src/components/** TSX through it, so a regression in its resolution order surfaces as MODULE_NOT_FOUND or a silent undefined inside an unrelated chart suite.

Covered branches:

case behaviour pinned
TS entry / TSX entry transpile + exports, React JSX factory
mock precedence mock(id) wins over relative, @site/, and require
mock returns undefined falls through to real resolution
nested relative import ./middle importing ./leaf re-enters the loader (the regression the module doc comment records)
directory import ./widget -> widget/index.tsx
precedence widget.ts wins over widget/index.ts
@site/... resolves against repo root
@site/*.json parsed, not evaluated
bare specifier falls through to node require
unresolvable relative throws rather than resolving to undefined
__importDefault interop a stub without __esModule is the default export; a { default: ... } stub without __esModule reads back undefined

Fixtures are temp dirs only — no network, no coupling to src/.

Verified locally: node --test scripts/lib/load-tsx.test.js -> 12 pass, 0 fail. Formatted with the repo's prettier.

Related Issue

Closes #1270

Disjointness

Checked against every open PR in this repo: #1263 claims scripts/fetch-registry-data.js, #1260 lib/request-queue, #1266 scripts/fetch-f* HTML sanitization, #1269 a dead Justfile recipe, #1264 generated analytics data. None reads or writes scripts/lib/load-tsx.js or scripts/lib/load-tsx.test.js. Issue #1168 tracks sbom/api.js, card-template.mjs, build-metrics.mjs, tap-promotions.mjs, graphql-queries.mjs — a disjoint module set.


Filed by quality agent (hold-gated mode). Human review required.

— hive: agent=quality backend=copilot model=claude-opus-5

scripts/lib/load-tsx.js is shared test infrastructure — countme-analytics-charts.test.js,
image-churn-charts.test.js and report-chart.test.js all load real src/ components
through loadTsxModule — and it had no test importing it. A regression in its
resolution order surfaces only as a confusing failure inside an unrelated chart suite.

Adds scripts/lib/load-tsx.test.js (12 node:test cases) covering every resolution
branch: mock-first precedence, mock-returns-undefined fallthrough, nested relative
imports routed back through the loader (the MODULE_NOT_FOUND regression the module's
doc comment records), directory/index resolution and .ts-over-directory precedence,
@site/ repo-root resolution plus the @site/*.json parse branch, bare-specifier
fallthrough to require, a loud failure on an unresolvable relative import, and the
__importDefault interop contract every stub author has to satisfy.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: sec-check[bot] <sec-check[bot]@users.noreply.github.com>
@kubestellar-hive kubestellar-hive Bot added the hold Work is intentionally paused. label Sep 16, 2026
@kubestellar-hive kubestellar-hive Bot added quality Code quality or test-coverage work. testing Test authoring or test infrastructure. agent/quality Filed or owned by the quality agent. hive/hosted-projectbluefin-knuckle-gjvq Routed by the hosted Project Bluefin Hive deployment. labels Sep 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent/quality Filed or owned by the quality agent. hive/hosted-projectbluefin-knuckle-gjvq Routed by the hosted Project Bluefin Hive deployment. hold Work is intentionally paused. quality Code quality or test-coverage work. testing Test authoring or test infrastructure.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[quality] coverage-gap: scripts/lib/load-tsx.js has no test that imports it — three chart suites depend on it

0 participants