Skip to content

Commit ebf38e2

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

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
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/utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { setInterval } from "timers/promises";
44

55
export function isUsingLocalAtlas() {
66
// eslint-disable-next-line no-process-env
7+
console.log(process.env);
78
return !process.env.MONGODB_ATLAS_URI;
89
}
910
export function uri() {

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

Lines changed: 4 additions & 3 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";
@@ -92,6 +92,7 @@ class PatchedVectorStore extends MongoDBAtlasVectorSearch {
9292
if (results.length === documents.length) {
9393
return docs;
9494
}
95+
console.log('waiting for results', results);
9596
await setTimeout(1000);
9697
}
9798
}
@@ -108,13 +109,13 @@ function getEmbeddings() {
108109
}
109110

110111
test("MongoDBStore sets client metadata", () => {
111-
const spy = jest.spyOn(client, "appendMetadata");
112+
const spy = vi.spyOn(client, "appendMetadata");
112113
// eslint-disable-next-line no-new
113114
new PatchedVectorStore(getEmbeddings(), {
114115
collection,
115116
});
116117
expect(spy).toHaveBeenCalledWith({ name: "langchainjs_vector" });
117-
jest.clearAllMocks();
118+
vi.clearAllMocks();
118119
});
119120

120121
test("MongoDBAtlasVectorSearch with external ids", async () => {

0 commit comments

Comments
 (0)