Skip to content

armgit / mem0

Public Imported from GitHub
0

The Memory Layer for AI Agents - Drop-in memory infrastructure for AI agents and apps. Context that persists. Built for production.

test: update integration tests for v1.1 output_format (#4847)

Kartik93a51f476327
diff --git a/mem0-ts/src/client/tests/integration/crud.test.ts b/mem0-ts/src/client/tests/integration/crud.test.ts
index d0771b11f..d3c8a703e 100644
--- a/mem0-ts/src/client/tests/integration/crud.test.ts
+++ b/mem0-ts/src/client/tests/integration/crud.test.ts
@@ -120,10 +120,13 @@ describeIntegration("MemoryClient Integration — CRUD", () => {
// ─── Get all ──────────────────────────────────────────────
describe("get all memories", () => {
test("returns all memories for test user", async () => {
- const memories = await client.getAll({
+ const response = await client.getAll({
filters: { user_id: TEST_USER_ID },
});
+ // v1.1 output_format returns { results: [...] }
+ expect(response).toHaveProperty("results");
+ const memories = (response as any).results;
expect(Array.isArray(memories)).toBe(true);
expect(memories.length).toBeGreaterThanOrEqual(memoryIds.length);
@@ -142,6 +145,7 @@ describeIntegration("MemoryClient Integration — CRUD", () => {
// Paginated response is an object with results array
expect(page1).toBeDefined();
+ expect(page1).toHaveProperty("results");
});
});
@@ -197,11 +201,14 @@ describeIntegration("MemoryClient Integration — CRUD", () => {
expect(result).toHaveProperty("eventId");
});
- test("getAll for non-existent user returns empty array", async () => {
- const memories = await client.getAll({
+ test("getAll for non-existent user returns empty results", async () => {
+ const response = await client.getAll({
filters: { user_id: `nonexistent-user-${randomUUID()}` },
});
+ // v1.1 output_format returns { results: [...] }
+ expect(response).toHaveProperty("results");
+ const memories = (response as any).results;
expect(Array.isArray(memories)).toBe(true);
expect(memories.length).toBe(0);
});
diff --git a/mem0-ts/src/client/tests/integration/helpers.ts b/mem0-ts/src/client/tests/integration/helpers.ts
index b8890a3eb..84279375a 100644
--- a/mem0-ts/src/client/tests/integration/helpers.ts
+++ b/mem0-ts/src/client/tests/integration/helpers.ts
@@ -67,10 +67,14 @@ export async function waitForMemories(
maxRetries = 4,
): Promise<Memory[]> {
for (let attempt = 1; attempt <= maxRetries; attempt++) {
- const memories = await withRetry(() =>
+ const response = await withRetry(() =>
client.getAll({ filters: { user_id: userId } }),
);
- if (Array.isArray(memories) && memories.length >= minCount) {
+ // v1.1 output_format returns { results: [...] }
+ const memories = Array.isArray(response)
+ ? response
+ : ((response as any)?.results ?? []);
+ if (memories.length >= minCount) {
return memories;
}
if (attempt < maxRetries) {