Skip to content

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

Closed
EagleEyez1 wants to merge 1 commit into
garrytan:masterfrom
EagleEyez1:fix/embed-test-mock-completeness
Closed

EagleEyez1 wants to merge 1 commit into
garrytan: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
@garrytan

garrytan commented Jun 8, 2026

Copy link
Copy Markdown
Owner

Thanks for this contribution — and apologies for the slow triage. We did a full pass over the entire PR backlog. gbrain has moved fast, and the maintainer's larger "cathedral" rewrites have superseded a big share of community PRs: the AI gateway + recipes + user_provided_models system replaced almost all individual provider PRs; #1805 fixed the whole Postgres module-singleton class; #1542 unified the type taxonomy; #1657 the retrieval path; #1802 the doctor; and so on.

We're closing this one in that cleanup — either the fix already landed on master, it duplicates another PR or merged change, or it's outside the current merge bar. Where a closed PR carried a genuinely valuable idea, we've recorded it in docs/designs/COMMUNITY_IDEAS.md so nothing good is lost (a few may graduate into TODOs).

Please don't read the close as a judgment of the work — thank you for contributing. If you believe the underlying issue is still live on the latest master, reopen with a quick note and we'll take another look. 🙏

@garrytan garrytan closed this Jun 8, 2026
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.

2 participants