Skip to content

Fix ESM parse error for isbinaryfile mock in tests#133

Merged
antonym merged 1 commit intomasterfrom
fix/isbinaryfile-esm-mock
Mar 15, 2026
Merged

Fix ESM parse error for isbinaryfile mock in tests#133
antonym merged 1 commit intomasterfrom
fix/isbinaryfile-esm-mock

Conversation

@antonym
Copy link
Copy Markdown
Member

@antonym antonym commented Mar 15, 2026

Summary

  • jest.mock('isbinaryfile') without a factory still attempts to parse the real ESM-only module to auto-generate the mock, causing a SyntaxError: Cannot use import statement outside a module failure
  • Provide an explicit factory function () => ({ isBinaryFile: jest.fn() }) so Jest never loads the real module

Follows up on #132 which addressed this for CI but the fix didn't fully prevent the ESM parse on all environments.

jest.mock('isbinaryfile') without a factory still attempts to parse the
real ESM module for auto-mocking. Provide an explicit factory function
so Jest never loads the real module.
@kilo-code-bot
Copy link
Copy Markdown

kilo-code-bot bot commented Mar 15, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

The change correctly updates the isbinaryfile mock to explicitly export the isBinaryFile function, which is necessary for proper ESM module mocking. The mock is used correctly in the test on line 177 where it's destructured, and the mock behavior (using mockResolvedValueOnce) is appropriate for the async function.

Files Reviewed (1 file)
  • tests/unit/app.test.js - ESM mock update for isbinaryfile module

@antonym antonym merged commit 53bb845 into master Mar 15, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant