Skip to content

fix(tests): complete embed.ts mock so later tests can import embed#116

Open
EagleEyez1 wants to merge 1 commit intogarrytan:masterfrom
EagleEyez1:fix/embed-test-mock-completeness
Open

fix(tests): complete embed.ts mock so later tests can import embed#116
EagleEyez1 wants to merge 1 commit intogarrytan:masterfrom
EagleEyez1:fix/embed-test-mock-completeness

Conversation

@EagleEyez1
Copy link
Copy Markdown

Summary

test/embed.test.ts mocks ../src/core/embedding.ts but the mock only provides embedBatch. Because Bun's mock.module() is process-global (not per-file), once that test runs, any later test whose transitive imports touch embedding.ts#embed fails to load with:

SyntaxError: Export named 'embed' not found in module
  src/core/embedding.ts
      at loadAndEvaluateModule (2:1)

The mock now mirrors the full public surface of embedding.ts (embed, embedBatch, EMBEDDING_MODEL, EMBEDDING_DIMENSIONS). Pure test-shape change — no production code affected, no existing assertions changed.

Repro

bun test test/embed.test.ts test/e2e/mechanical.test.ts

Before: 3 pass, 1 fail, 1 error
After: 3 pass, 0 fail

Full suite (on my machine, bun 1.3.11, no DATABASE_URL):

  • Before: 469 pass, 3 fail, 3 errors
  • After: 590 pass, 0 fail, 126 skip (DB-backed tests skipped as expected)

Test plan

  • bun test test/embed.test.ts — existing concurrency assertions still hold
  • bun test — full non-DB suite green
  • rg "mock.module" test/ reviewed — no other mocks with the same partial-shape problem

Out of scope

A more robust fix would unmock in an afterAll so later test files see the real module. Bun doesn't have mock.unmock.module() yet (there's ongoing discussion upstream), so matching the full shape is the minimal correct fix today.

Bun's `mock.module()` is process-global and persists after the test
file that installs it finishes, so any test loaded later that imports
`embed` from src/core/embedding.ts was failing with:

    SyntaxError: Export named 'embed' not found in module
    src/core/embedding.ts

The mock only provided `embedBatch`. Add the `embed` function and the
two exported constants (EMBEDDING_MODEL, EMBEDDING_DIMENSIONS) so the
mock matches the real module's public surface. No behavior change to
the existing test assertions.

Before: 3 pass, 1 fail, 1 error on
    bun test test/embed.test.ts test/e2e/mechanical.test.ts
After:  3 pass, 0 fail on the same invocation; 590 pass / 0 fail on
    the full non-DB suite.
@EagleEyez1 EagleEyez1 force-pushed the fix/embed-test-mock-completeness branch from 4780447 to 7b39dcf Compare April 14, 2026 14:14
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