refactor: update global test setup/teardown to load SDK version and import MemoryClient dynamically
This commit is contained in:
@@ -4,12 +4,15 @@
|
|||||||
* Runs a full project cleanup before any integration test starts,
|
* Runs a full project cleanup before any integration test starts,
|
||||||
* then waits 10 seconds for the async cleanup to propagate.
|
* then waits 10 seconds for the async cleanup to propagate.
|
||||||
*/
|
*/
|
||||||
import { MemoryClient } from "../../mem0";
|
|
||||||
|
|
||||||
export default async function globalSetup() {
|
export default async function globalSetup() {
|
||||||
|
const pkg = require("../../../../package.json");
|
||||||
|
(globalThis as any).__MEM0_SDK_VERSION__ = pkg.version;
|
||||||
|
|
||||||
const apiKey = process.env.MEM0_API_KEY;
|
const apiKey = process.env.MEM0_API_KEY;
|
||||||
if (!apiKey) return; // skip if no key — tests will be skipped too
|
if (!apiKey) return; // skip if no key — tests will be skipped too
|
||||||
|
|
||||||
|
const { MemoryClient } = await import("../../mem0");
|
||||||
const client = new MemoryClient({ apiKey });
|
const client = new MemoryClient({ apiKey });
|
||||||
await client.ping();
|
await client.ping();
|
||||||
|
|
||||||
|
|||||||
@@ -4,12 +4,15 @@
|
|||||||
* Runs a full project cleanup after all integration tests complete
|
* Runs a full project cleanup after all integration tests complete
|
||||||
* so no test data is left behind.
|
* so no test data is left behind.
|
||||||
*/
|
*/
|
||||||
import { MemoryClient } from "../../mem0";
|
|
||||||
|
|
||||||
export default async function globalTeardown() {
|
export default async function globalTeardown() {
|
||||||
|
const pkg = require("../../../../package.json");
|
||||||
|
(globalThis as any).__MEM0_SDK_VERSION__ = pkg.version;
|
||||||
|
|
||||||
const apiKey = process.env.MEM0_API_KEY;
|
const apiKey = process.env.MEM0_API_KEY;
|
||||||
if (!apiKey) return;
|
if (!apiKey) return;
|
||||||
|
|
||||||
|
const { MemoryClient } = await import("../../mem0");
|
||||||
const client = new MemoryClient({ apiKey });
|
const client = new MemoryClient({ apiKey });
|
||||||
await client.ping();
|
await client.ping();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user