fix: repair broken Jest suite (CI red since SARIF version change) + add --output alias#20
Open
dmchaledev wants to merge 1 commit into
Open
fix: repair broken Jest suite (CI red since SARIF version change) + add --output alias#20dmchaledev wants to merge 1 commit into
dmchaledev wants to merge 1 commit into
Conversation
… add --output alias The `import.meta.url` introduced in src/sarif.ts could not be compiled by ts-jest's CommonJS transform, which silently broke 3 of 4 test suites — only scorer.test.ts ran. CI has been failing on main since that change. - Run Jest in ES module mode (ts-jest/presets/default-esm) so it matches the package's actual ESM runtime and `import.meta` compiles. - Fix a stale assertion in sarif.test.ts that hardcoded version "0.0.1"; it now validates against the real package.json version. - Accept `--output=` as an alias for `--format=` so the documented quick-start examples (`--output=sarif`) work as written instead of erroring out. - Extract a pure, testable parseArgs() from the CLI and guard main() so it only runs when invoked as the binary, plus add cli.test.ts covering arg parsing. Test suites: 4 passed (86 tests). Typecheck, lint, and build all pass.
This was referenced Jun 22, 2026
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.
Summary
CI has been failing on
mainsinced0bf659("read SARIF tool version from package.json"). That commit addedcreateRequire(import.meta.url)tosrc/sarif.ts, which ts-jest's CommonJS transform cannot compile (TS1343: 'import.meta' is only allowed when '--module' is es2020/esnext/nodenext…, plus a duplicate-requireerror).The breakage was silent: any test suite that imports
sarif.ts(directly or transitively) failed to compile, so it never ran. Onlyscorer.test.tswas actually executing — 3 of 4 suites were dead, and thenpm teststep in CI exits non-zero.What changed
ts-jest/presets/default-esm+useESM, andnode --experimental-vm-modulesin thetestscript). This matches the package's real ESM runtime ("type": "module",module: NodeNext) soimport.metacompiles instead of being forced through a CommonJS transform.sarif.test.tshardcoded the SARIF tool version as"0.0.1". Sinced0bf659reads it dynamically frompackage.json(1.0.1), the assertion was wrong — it just never ran. It now validates against the realpackage.jsonversion.--output=as an alias for--format=in the CLI. The README quick-start and the published dev.to launch post both document--output=sarif, but the CLI only understood--format=— so the documented copy-paste command errored out with exit code 2. Both flags now work.parseArgs()frommain()and guardmain()so it only runs when invoked as the binary (not when imported by tests). Addscli.test.tscovering arg parsing, the--outputalias, and error cases.Verification
All run locally and pass:
npx tsc --noEmit— cleannpm run lint— 0 warningsnpm test— 86 passed, 4 suitesnpm run build— cleannode dist/cli.js ./examples/vulnerable-config.json --output=sarif --exit-code— now emits SARIF (previously:Error: Unknown flag "--output=sarif", exit 2)https://claude.ai/code/session_01NxTdGKzVSjYp5eWKEmnV7a
Generated by Claude Code