[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
Open
kubestellar-hive[bot] wants to merge 1 commit into
kubestellar-hive[bot] wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Test Improvement
Adds
scripts/lib/load-tsx.test.js— 12node:testcases forscripts/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), functionloadTsxModuleinscripts/lib/load-tsx.js. No production file is touched; no other file is modified.load-tsx.jsis shared test infrastructure:scripts/countme-analytics-charts.test.js,scripts/image-churn-charts.test.jsandscripts/report-chart.test.jsall load realsrc/components/**TSX through it, so a regression in its resolution order surfaces asMODULE_NOT_FOUNDor a silentundefinedinside an unrelated chart suite.Covered branches:
mock(id)wins over relative,@site/, andrequireundefined./middleimporting./leafre-enters the loader (the regression the module doc comment records)./widget->widget/index.tsxwidget.tswins overwidget/index.ts@site/...@site/*.jsonrequireundefined__importDefaultinterop__esModuleis the default export; a{ default: ... }stub without__esModulereads backundefinedFixtures 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, #1260lib/request-queue, #1266scripts/fetch-f*HTML sanitization, #1269 a dead Justfile recipe, #1264 generated analytics data. None reads or writesscripts/lib/load-tsx.jsorscripts/lib/load-tsx.test.js. Issue #1168 trackssbom/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