Repository navigation
fix(tests): complete embed.ts mock so later tests can import embed - #116
EagleEyez1 wants to merge 1 commit into
Conversation
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.
4780447 to
7b39dcf
Compare
|
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. 🙏 |
Summary
test/embed.test.tsmocks../src/core/embedding.tsbut the mock only providesembedBatch. Because Bun'smock.module()is process-global (not per-file), once that test runs, any later test whose transitive imports touchembedding.ts#embedfails to load with: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
Before:
3 pass, 1 fail, 1 errorAfter:
3 pass, 0 failFull suite (on my machine,
bun 1.3.11, noDATABASE_URL):469 pass, 3 fail, 3 errors590 pass, 0 fail, 126 skip(DB-backed tests skipped as expected)Test plan
bun test test/embed.test.ts— existing concurrency assertions still holdbun test— full non-DB suite greenrg "mock.module" test/reviewed — no other mocks with the same partial-shape problemOut of scope
A more robust fix would unmock in an
afterAllso later test files see the real module. Bun doesn't havemock.unmock.module()yet (there's ongoing discussion upstream), so matching the full shape is the minimal correct fix today.