1- import { beforeAll , expect , vi , test , type MockInstance } from "vitest" ;
1+ import {
2+ afterAll ,
3+ beforeAll ,
4+ beforeEach ,
5+ describe ,
6+ expect ,
7+ vi ,
8+ test ,
9+ type MockInstance ,
10+ } from "vitest" ;
211import { Collection , MongoClient } from "mongodb" ;
312import { setTimeout } from "timers/promises" ;
413import { OpenAIEmbeddings , AzureOpenAIEmbeddings } from "@langchain/openai" ;
@@ -33,7 +42,7 @@ beforeAll(async () => {
3342 client = new MongoClient ( uri ( ) , { monitorCommands : true } ) ;
3443 await client . connect ( ) ;
3544
36- const namespace = "langchain.test " ;
45+ const namespace = "langchain_test_db.langchain_test " ;
3746 const [ dbName , collectionName ] = namespace . split ( "." ) ;
3847 collection = await client . db ( dbName ) . createCollection ( collectionName ) ;
3948
@@ -108,13 +117,13 @@ function getEmbeddings() {
108117}
109118
110119test ( "MongoDBStore sets client metadata" , ( ) => {
111- const spy = jest . spyOn ( client , "appendMetadata" ) ;
120+ const spy = vi . spyOn ( client , "appendMetadata" ) ;
112121 // eslint-disable-next-line no-new
113122 new PatchedVectorStore ( getEmbeddings ( ) , {
114123 collection,
115124 } ) ;
116125 expect ( spy ) . toHaveBeenCalledWith ( { name : "langchainjs_vector" } ) ;
117- jest . clearAllMocks ( ) ;
126+ vi . clearAllMocks ( ) ;
118127} ) ;
119128
120129test ( "MongoDBAtlasVectorSearch with external ids" , async ( ) => {
@@ -199,7 +208,7 @@ test("MongoDBAtlasVectorSearch with Maximal Marginal Relevance", async () => {
199208
200209 const standardRetriever = await vectorStore . asRetriever ( ) ;
201210
202- const standardRetrieverOutput = await standardRetriever . getRelevantDocuments (
211+ const standardRetrieverOutput = await standardRetriever . _getRelevantDocuments (
203212 "foo"
204213 ) ;
205214 expect ( output ) . toHaveLength ( texts . length ) ;
@@ -218,7 +227,7 @@ test("MongoDBAtlasVectorSearch with Maximal Marginal Relevance", async () => {
218227 } ,
219228 } ) ;
220229
221- const retrieverOutput = await retriever . getRelevantDocuments ( "foo" ) ;
230+ const retrieverOutput = await retriever . _getRelevantDocuments ( "foo" ) ;
222231 expect ( output ) . toHaveLength ( texts . length ) ;
223232
224233 const retrieverActual = retrieverOutput . map ( ( doc ) => doc . pageContent ) ;
0 commit comments