fix(test): run Jest as ESM to unbreak CI on main#12
Open
dmchaledev wants to merge 1 commit into
Open
Conversation
Commit #9 added `import.meta.url`/`createRequire` to src/sarif.ts to read the package version dynamically, but jest.config.cjs forced ts-jest to compile with `module: CommonJS`, where `import.meta` is illegal (TS1343) and `const require` collides with CommonJS's `require` (TS2441). Two of three test suites failed to compile, so `npm test` — and therefore CI on main — has been red since #9. - Switch jest to the ts-jest ESM preset (useESM + ESNext) so the test environment matches the NodeNext ESM production build. - Run Jest via `node --experimental-vm-modules` so ESM modules load. - Fix a stale sarif test that hardcoded version "0.0.1"; it was masked by the compile failure. It now asserts the SARIF driver version matches package.json (the behavior #9 introduced). All 3 suites pass (75 tests); typecheck, lint, build, and CLI smoke test remain green. https://claude.ai/code/session_01PQ2DZcjvnKu8ge5t6ufcn9
This was referenced Jun 2, 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 on
mainhas been red since #9. The last threemainworkflow runs all fail at theTeststep.Root cause
Commit #9 ("fix: read SARIF tool version from package.json") added to
src/sarif.ts:The production build is ESM (
module: NodeNext), so that's correct fornpm run build. Butjest.config.cjsforced ts-jest to compile tests withmodule: 'CommonJS', where:import.metais illegal → TS1343const requirecollides with CommonJS's reservedrequire→ TS2441So two of three test suites failed to compile,
npm testexited non-zero, and CI went red. The verbatim CI error:Fix
Run Jest as ESM so the test environment matches the NodeNext ESM production build (rather than transpiling source to CommonJS):
jest.config.cjs: switch to thets-jest/presets/default-esmpreset (useESM: true,extensionsToTreatAsEsm, non-hybridmodule: ESNext).package.json: run Jest vianode --experimental-vm-modulesso ESM modules load.src/__tests__/sarif.test.ts: a stale test hardcodedexpect(...version).toBe('0.0.1'). It was masked by the compile failure — fix: read SARIF tool version from package.json #9 made the version dynamic (now1.0.1). It now asserts the SARIF driver version equalspackage.json's version and matches a SemVer shape, so it stays correct across version bumps.Verification (local)
No production code changes — only test config and one stale assertion.
Out of scope (noted for follow-up)
While investigating I noticed the README Quick Start and
dev-to/launch-post.mdadvertise--output=sarif, but the CLI only accepts--format=(the canonical flag used everywhere else). The documented command currently errors withUnknown flag "--output=sarif"and exits 2. Left out of this PR to keep it focused on the CI fix — happy to send a separate doc fix.https://claude.ai/code/session_01PQ2DZcjvnKu8ge5t6ufcn9
Generated by Claude Code