Skip to content

Commit 12b6fab

Browse files
committed
test(mongodb): fix mongodb tests
1 parent a4a60d2 commit 12b6fab

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

libs/providers/langchain-mongodb/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"lint:fix": "pnpm lint:eslint --fix && pnpm lint:dpdm",
2222
"clean": "rm -rf .turbo dist/",
2323
"test:watch": "vitest",
24-
"test:int": "vitest run --mode int --testTimeout 100000 --maxWorkers=50%",
24+
"test:int": "vitest run --mode int --testTimeout 10000 --maxWorkers=50%",
2525
"format": "prettier --config .prettierrc --write \"src\"",
2626
"format:check": "prettier --config .prettierrc --check \"src\""
2727
},

libs/providers/langchain-mongodb/src/tests/storage.int.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { describe, test, expect, beforeAll, afterAll } from "vitest";
1+
import { describe, test, expect, beforeAll, afterAll, afterEach } from "vitest";
22
import { v4 as uuidv4 } from "uuid";
33
import { Collection, MongoClient, ServerApiVersion } from "mongodb";
44
import { MongoDBStore } from "../storage.js";

libs/providers/langchain-mongodb/src/tests/vectorstores.int.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { beforeAll, expect, vi, test, type MockInstance } from "vitest";
1+
import { afterAll, beforeAll, beforeEach, describe, expect, vi, test, type MockInstance } from "vitest";
22
import { Collection, MongoClient } from "mongodb";
33
import { setTimeout } from "timers/promises";
44
import { 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

110110
test("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

120120
test("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

Comments
 (0)