You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
test: type the npm-advisory mocks and range events (part of #1491) - #1559
Part of #1491 (the backlog does not go to zero here): the test type-check gate reports 113 pre-existing errors on main today, and this removes 54 of them (113 -> 59).
tests/scanner-npm-advisory.test.ts (31 errors): type the three shared mocks (queryBatchMock, getVulnMock, queryNpmAdvisoryGapsMock) and the remediation module stubs, add the required incompletePolicy to the ParsedOptions fixture, and drop the versions/references properties that OsvVuln does not declare (they were ignored at runtime and never asserted).
tests/local-advisory-source.test.ts (12 errors): derive the range-event type from OsvVuln instead of Record<string, string>, so the { introduced } / { fixed } / { last_affected } literals no longer widen to optional-undefined records.
tests/scripts/pr-scan-delta.test.ts (11 errors): add scripts/pr-scan-delta.d.mts so the .mjs helper is typed; the callback parameters become contextually typed instead of implicitly any.
Only test files and one type declaration change; no runtime behaviour.
Checks
node scripts/typecheck-changed-tests.mjs upstream/main: 2 changed test file(s) clean, no new errors. 59 pre-existing error(s) carried over.
Type the mocked OSV batch and npm advisory-gap functions, the validated
options fixture, and the range-event helper, so the compiler stops
inferring never[] and jest mocks stop rejecting resolved values.
Drop the OsvVuln properties the type does not declare (versions,
references); they were ignored at runtime and never asserted.
Add a declaration file for scripts/pr-scan-delta.mjs so the delta tests
are typed instead of implicitly any.
The reason will be displayed to describe this comment to others. Learn more.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
The module declares the dependency-delta row and result types, function signatures, and marker constant.
Advisory Test Updates
Layer / File(s)
Summary
Advisory test types and fixtures tests/local-advisory-source.test.ts, tests/scanner-npm-advisory.test.ts
The tests use OSV-derived event types and typed advisory mocks. Shared options include incompletePolicy: "warn", and two npm-only fixtures omit empty versions and references fields.
The changes update test typing and helper declarations without an established runtime regression. No actionable merge-blocking issue remains; merge after normal checks pass.
Pre-merge checks: 7
Check name
Status
Explanation
Title check
The title follows the required "type: short description" form with the allowed type "test", lowercase after the colon, and no trailing period. It matches the main change, which types the npm-advisory …
Description check
The description follows the template's "What changed and why" section and explains the change clearly. It lists the affected test files, the reduction from 113 to 59 type errors, and the checks that w…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Linked Issue
I found Refs #1491 in the pull request body. The pull request references a GitHub issue as required.
Closes Keyword Matches Scope
I found no issue-closing keyword in the PR body. It uses Refs #1491, so merging will not auto-close the issue through that reference.
No New Runtime Dependency
Users get no new runtime dependency. I confirmed that the PR does not change any package.json file.
Full details: Title check
Explanation
The title follows the required "type: short description" form with the allowed type "test", lowercase after the colon, and no trailing period. It matches the main change, which types the npm-advisory test mocks and range-event helpers. The "(part of #1491)" suffix is extra context and does not affect the check.
Full details: Description check
Explanation
The description follows the template's "What changed and why" section and explains the change clearly. It lists the affected test files, the reduction from 113 to 59 type errors, and the checks that were run. The template's "Closes #" line is missing. The PR uses "Part of #1491" and "Refs #1491" instead, which is reasonable because the change only partly resolves that issue. The description is mostly complete, so the check passes.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Any matching disabled override withholds approval, regardless of risk. Otherwise, the strictest explicitly set limit wins for each score. Limits omitted by all matching overrides inherit the global configuration.
Not set means no limit was configured after inheritance. Use @coderabbitai configuration to inspect the resolved settings and their sources.
Reviewing files that changed from the base of the PR and between c98c080 and 40aefc8.
Files selected for processing: 3
scripts/pr-scan-delta.d.mts
tests/local-advisory-source.test.ts
tests/scanner-npm-advisory.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Thanks @prx-my. This clears 54 of the test type errors (112 on main to 58 merged), with the same number of tests and assertions in every file it touches. The two fixture tweaks don't change behaviour, and the declaration file matches what pr-scan-delta.mjs actually exports. Refs #1491 is right since the backlog isn't at zero yet.
Together they take the test type-check backlog from 112 errors to 0, with no runtime changes. Would you be able to merge them with the website-check override? Once they land I'll open the small follow-up that drops the backlog allowance from scripts/typecheck-changed-tests.mjs and updates CONTRIBUTING.md, which is the last item in #1491.
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
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.
What changed and why
Part of #1491 (the backlog does not go to zero here): the test type-check gate reports 113 pre-existing errors on
maintoday, and this removes 54 of them (113 -> 59).tests/scanner-npm-advisory.test.ts(31 errors): type the three shared mocks (queryBatchMock,getVulnMock,queryNpmAdvisoryGapsMock) and the remediation module stubs, add the requiredincompletePolicyto theParsedOptionsfixture, and drop theversions/referencesproperties thatOsvVulndoes not declare (they were ignored at runtime and never asserted).tests/local-advisory-source.test.ts(12 errors): derive the range-event type fromOsvVulninstead ofRecord<string, string>, so the{ introduced }/{ fixed }/{ last_affected }literals no longer widen to optional-undefined records.tests/scripts/pr-scan-delta.test.ts(11 errors): addscripts/pr-scan-delta.d.mtsso the.mjshelper is typed; the callback parameters become contextually typed instead of implicitlyany.Only test files and one type declaration change; no runtime behaviour.
Checks
node scripts/typecheck-changed-tests.mjs upstream/main: 2 changed test file(s) clean, no new errors. 59 pre-existing error(s) carried over.npx tsc -p tsconfig.test.json --noEmit: 113 -> 59 errors.npm test -- tests/local-advisory-source.test.ts tests/scanner-npm-advisory.test.ts tests/scripts/pr-scan-delta.test.ts: 3 suites, 58 tests passed.npm run lint:tests: passed.npm run build: clean.Refs #1491