mirror of
https://github.com/openclaw/openclaw.git
synced 2026-02-19 18:39:20 -05:00
perf(test): mock chokidar in memory tests
This commit is contained in:
@@ -6,6 +6,14 @@ import { getMemorySearchManager, type MemoryIndexManager } from "./index.js";
|
||||
|
||||
let embedBatchCalls = 0;
|
||||
|
||||
// Unit tests: avoid importing the real chokidar implementation (native fsevents, etc.).
|
||||
vi.mock("chokidar", () => ({
|
||||
default: {
|
||||
watch: () => ({ on: () => {}, close: async () => {} }),
|
||||
},
|
||||
watch: () => ({ on: () => {}, close: async () => {} }),
|
||||
}));
|
||||
|
||||
vi.mock("./sqlite-vec.js", () => ({
|
||||
loadSqliteVecExtension: async () => ({ ok: false, error: "sqlite-vec disabled in tests" }),
|
||||
}));
|
||||
|
||||
@@ -7,6 +7,14 @@ import { getMemorySearchManager, type MemoryIndexManager } from "./index.js";
|
||||
const embedBatch = vi.fn(async () => []);
|
||||
const embedQuery = vi.fn(async () => [0.5, 0.5, 0.5]);
|
||||
|
||||
// Unit tests: avoid importing the real chokidar implementation (native fsevents, etc.).
|
||||
vi.mock("chokidar", () => ({
|
||||
default: {
|
||||
watch: () => ({ on: () => {}, close: async () => {} }),
|
||||
},
|
||||
watch: () => ({ on: () => {}, close: async () => {} }),
|
||||
}));
|
||||
|
||||
vi.mock("./sqlite-vec.js", () => ({
|
||||
loadSqliteVecExtension: async () => ({ ok: false, error: "sqlite-vec disabled in tests" }),
|
||||
}));
|
||||
|
||||
@@ -7,6 +7,14 @@ import { getMemorySearchManager, type MemoryIndexManager } from "./index.js";
|
||||
const embedBatch = vi.fn(async (texts: string[]) => texts.map(() => [0, 1, 0]));
|
||||
const embedQuery = vi.fn(async () => [0, 1, 0]);
|
||||
|
||||
// Unit tests: avoid importing the real chokidar implementation (native fsevents, etc.).
|
||||
vi.mock("chokidar", () => ({
|
||||
default: {
|
||||
watch: () => ({ on: () => {}, close: async () => {} }),
|
||||
},
|
||||
watch: () => ({ on: () => {}, close: async () => {} }),
|
||||
}));
|
||||
|
||||
vi.mock("./sqlite-vec.js", () => ({
|
||||
loadSqliteVecExtension: async () => ({ ok: false, error: "sqlite-vec disabled in tests" }),
|
||||
}));
|
||||
|
||||
@@ -7,6 +7,14 @@ import { getMemorySearchManager, type MemoryIndexManager } from "./index.js";
|
||||
const embedBatch = vi.fn(async (texts: string[]) => texts.map(() => [0, 1, 0]));
|
||||
const embedQuery = vi.fn(async () => [0, 1, 0]);
|
||||
|
||||
// Unit tests: avoid importing the real chokidar implementation (native fsevents, etc.).
|
||||
vi.mock("chokidar", () => ({
|
||||
default: {
|
||||
watch: () => ({ on: () => {}, close: async () => {} }),
|
||||
},
|
||||
watch: () => ({ on: () => {}, close: async () => {} }),
|
||||
}));
|
||||
|
||||
vi.mock("./sqlite-vec.js", () => ({
|
||||
loadSqliteVecExtension: async () => ({ ok: false, error: "sqlite-vec disabled in tests" }),
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user