1- import { beforeAll , expect , vi , test , type MockInstance } from "vitest" ;
1+ import { afterAll , beforeAll , beforeEach , describe , expect , vi , test , type MockInstance } from "vitest" ;
22import { Collection , MongoClient } from "mongodb" ;
33import { setTimeout } from "timers/promises" ;
44import { OpenAIEmbeddings , AzureOpenAIEmbeddings } from "@langchain/openai" ;
@@ -33,7 +33,7 @@ beforeAll(async () => {
3333 client = new MongoClient ( uri ( ) , { monitorCommands : true } ) ;
3434 await client . connect ( ) ;
3535
36- const namespace = "langchain.test " ;
36+ const namespace = "langchain_test_db.langchain_test " ;
3737 const [ dbName , collectionName ] = namespace . split ( "." ) ;
3838 collection = await client . db ( dbName ) . createCollection ( collectionName ) ;
3939
@@ -108,13 +108,13 @@ function getEmbeddings() {
108108}
109109
110110test ( "MongoDBStore sets client metadata" , ( ) => {
111- const spy = jest . spyOn ( client , "appendMetadata" ) ;
111+ const spy = vi . spyOn ( client , "appendMetadata" ) ;
112112 // eslint-disable-next-line no-new
113113 new PatchedVectorStore ( getEmbeddings ( ) , {
114114 collection,
115115 } ) ;
116116 expect ( spy ) . toHaveBeenCalledWith ( { name : "langchainjs_vector" } ) ;
117- jest . clearAllMocks ( ) ;
117+ vi . clearAllMocks ( ) ;
118118} ) ;
119119
120120test ( "MongoDBAtlasVectorSearch with external ids" , async ( ) => {
@@ -199,7 +199,7 @@ test("MongoDBAtlasVectorSearch with Maximal Marginal Relevance", async () => {
199199
200200 const standardRetriever = await vectorStore . asRetriever ( ) ;
201201
202- const standardRetrieverOutput = await standardRetriever . getRelevantDocuments (
202+ const standardRetrieverOutput = await standardRetriever . _getRelevantDocuments (
203203 "foo"
204204 ) ;
205205 expect ( output ) . toHaveLength ( texts . length ) ;
@@ -218,7 +218,7 @@ test("MongoDBAtlasVectorSearch with Maximal Marginal Relevance", async () => {
218218 } ,
219219 } ) ;
220220
221- const retrieverOutput = await retriever . getRelevantDocuments ( "foo" ) ;
221+ const retrieverOutput = await retriever . _getRelevantDocuments ( "foo" ) ;
222222 expect ( output ) . toHaveLength ( texts . length ) ;
223223
224224 const retrieverActual = retrieverOutput . map ( ( doc ) => doc . pageContent ) ;
0 commit comments