fix(tests): complete embed.ts mock so later tests can import embed#116
Open
EagleEyez1 wants to merge 1 commit intogarrytan:masterfrom
Open
fix(tests): complete embed.ts mock so later tests can import embed#116EagleEyez1 wants to merge 1 commit intogarrytan:masterfrom
embed#116EagleEyez1 wants to merge 1 commit intogarrytan:masterfrom
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
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
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.