diff --git a/libs/checkpoint-validation/package.json b/libs/checkpoint-validation/package.json index 0aa64ae0..d87e01bd 100644 --- a/libs/checkpoint-validation/package.json +++ b/libs/checkpoint-validation/package.json @@ -55,6 +55,7 @@ "@testcontainers/mongodb": "^10.13.2", "@testcontainers/postgresql": "^10.13.2", "@tsconfig/recommended": "^1.0.3", + "@types/jest": "^29.5.13", "@types/uuid": "^10", "@typescript-eslint/eslint-plugin": "^6.12.0", "@typescript-eslint/parser": "^6.12.0", diff --git a/libs/checkpoint-validation/src/spec/getTuple.ts b/libs/checkpoint-validation/src/spec/getTuple.ts index 2ccd0bb4..a31c1647 100644 --- a/libs/checkpoint-validation/src/spec/getTuple.ts +++ b/libs/checkpoint-validation/src/spec/getTuple.ts @@ -5,7 +5,6 @@ import { uuid6, type BaseCheckpointSaver, } from "@langchain/langgraph-checkpoint"; -import { describe, it, beforeAll, afterAll, expect } from "@jest/globals"; import { mergeConfigs, RunnableConfig } from "@langchain/core/runnables"; import { CheckpointSaverTestInitializer } from "../types.js"; import { parentAndChildCheckpointTuplesWithWrites } from "./data.js"; diff --git a/libs/checkpoint-validation/src/spec/index.ts b/libs/checkpoint-validation/src/spec/index.ts index faa2b03e..ccce443d 100644 --- a/libs/checkpoint-validation/src/spec/index.ts +++ b/libs/checkpoint-validation/src/spec/index.ts @@ -1,5 +1,4 @@ import { type BaseCheckpointSaver } from "@langchain/langgraph-checkpoint"; -import { describe, beforeAll, afterAll } from "@jest/globals"; import { CheckpointSaverTestInitializer, TestTypeFilter } from "../types.js"; import { putTests } from "./put.js"; diff --git a/libs/checkpoint-validation/src/spec/list.ts b/libs/checkpoint-validation/src/spec/list.ts index 79fac0ec..a38992d6 100644 --- a/libs/checkpoint-validation/src/spec/list.ts +++ b/libs/checkpoint-validation/src/spec/list.ts @@ -4,7 +4,6 @@ import { uuid6, type BaseCheckpointSaver, } from "@langchain/langgraph-checkpoint"; -import { describe, it, beforeAll, afterAll, expect } from "@jest/globals"; import { mergeConfigs, RunnableConfig } from "@langchain/core/runnables"; import { CheckpointSaverTestInitializer } from "../types.js"; import { generateTuplePairs } from "./data.js"; diff --git a/libs/checkpoint-validation/src/spec/put.ts b/libs/checkpoint-validation/src/spec/put.ts index 469e557c..d2c16bfd 100644 --- a/libs/checkpoint-validation/src/spec/put.ts +++ b/libs/checkpoint-validation/src/spec/put.ts @@ -5,7 +5,6 @@ import { uuid6, type BaseCheckpointSaver, } from "@langchain/langgraph-checkpoint"; -import { describe, it, afterEach, beforeEach, expect } from "@jest/globals"; import { mergeConfigs, RunnableConfig } from "@langchain/core/runnables"; import { CheckpointSaverTestInitializer } from "../types.js"; import { initialCheckpointTuple } from "./data.js"; diff --git a/libs/checkpoint-validation/src/spec/putWrites.ts b/libs/checkpoint-validation/src/spec/putWrites.ts index 33389d59..43f179d2 100644 --- a/libs/checkpoint-validation/src/spec/putWrites.ts +++ b/libs/checkpoint-validation/src/spec/putWrites.ts @@ -5,7 +5,6 @@ import { uuid6, type BaseCheckpointSaver, } from "@langchain/langgraph-checkpoint"; -import { describe, it, beforeEach, afterEach, expect } from "@jest/globals"; import { mergeConfigs, RunnableConfig } from "@langchain/core/runnables"; import { CheckpointSaverTestInitializer } from "../types.js"; import { initialCheckpointTuple } from "./data.js"; diff --git a/libs/checkpoint-validation/src/spec/util.ts b/libs/checkpoint-validation/src/spec/util.ts index 35c3169e..36f0dab7 100644 --- a/libs/checkpoint-validation/src/spec/util.ts +++ b/libs/checkpoint-validation/src/spec/util.ts @@ -1,4 +1,3 @@ -import { expect } from "@jest/globals"; import { mergeConfigs, RunnableConfig } from "@langchain/core/runnables"; import { BaseCheckpointSaver, diff --git a/libs/checkpoint-validation/src/testUtils.ts b/libs/checkpoint-validation/src/testUtils.ts index 416d3654..af2d661b 100644 --- a/libs/checkpoint-validation/src/testUtils.ts +++ b/libs/checkpoint-validation/src/testUtils.ts @@ -1,5 +1,3 @@ -import { it } from "@jest/globals"; - // to make the type signature of the skipOnModules function a bit more readable export type SaverName = string; export type WhySkipped = string; @@ -21,7 +19,7 @@ export function it_skipForSomeModules( if (skipReason) { const skip = ( name: string, - test: () => void | Promise, + test: jest.ProvidesCallback | undefined, timeout?: number ) => { it.skip(`[because ${skipReason}] ${name}`, test, timeout); @@ -40,7 +38,7 @@ export function it_skipIfNot( if (!savers.includes(saverName)) { const skip = ( name: string, - test: () => void | Promise, + test: jest.ProvidesCallback | undefined, timeout?: number ) => { it.skip( diff --git a/libs/checkpoint-validation/src/tests/mongodb.spec.ts b/libs/checkpoint-validation/src/tests/mongodb.spec.ts index b7256443..d951af2b 100644 --- a/libs/checkpoint-validation/src/tests/mongodb.spec.ts +++ b/libs/checkpoint-validation/src/tests/mongodb.spec.ts @@ -1,4 +1,12 @@ import { specTest } from "../spec/index.js"; import { initializer } from "./mongoInitializer.js"; +import { isCI, isMSeriesMac } from "./utils.js"; -specTest(initializer); +// skipped on M1 macOS in CI because there's no container runtime available due to the reliance on nested +// virtualization, which isn't yet supported on Apple Silicon. +// For more details, see https://github.com/actions/runner-images/issues/9460#issuecomment-1981203045 +if (isMSeriesMac() && isCI()) { + it.skip(`${initializer.saverName} skipped on M1 macOS in CI because no container runtime is available`, () => {}); +} else { + specTest(initializer); +} diff --git a/libs/checkpoint-validation/src/tests/postgres.spec.ts b/libs/checkpoint-validation/src/tests/postgres.spec.ts index 828b2425..5d424493 100644 --- a/libs/checkpoint-validation/src/tests/postgres.spec.ts +++ b/libs/checkpoint-validation/src/tests/postgres.spec.ts @@ -1,4 +1,12 @@ import { specTest } from "../spec/index.js"; import { initializer } from "./postgresInitializer.js"; +import { isCI, isMSeriesMac } from "./utils.js"; -specTest(initializer); +// skipped on M1 macOS in CI because there's no container runtime available due to the reliance on nested +// virtualization, which isn't yet supported on Apple Silicon. +// For more details, see https://github.com/actions/runner-images/issues/9460#issuecomment-1981203045 +if (isMSeriesMac() && isCI()) { + it.skip(`${initializer.saverName} skipped on M1 macOS in CI because no container runtime is available`, () => {}); +} else { + specTest(initializer); +} diff --git a/libs/checkpoint-validation/src/tests/utils.ts b/libs/checkpoint-validation/src/tests/utils.ts new file mode 100644 index 00000000..1e89f2ed --- /dev/null +++ b/libs/checkpoint-validation/src/tests/utils.ts @@ -0,0 +1,10 @@ +import { platform, arch } from "node:os"; + +export function isMSeriesMac() { + return platform() === "darwin" && arch() === "arm64"; +} + +export function isCI() { + // eslint-disable-next-line no-process-env + return (process.env.CI ?? "").toLowerCase() === "true"; +} diff --git a/libs/checkpoint-validation/tsconfig.json b/libs/checkpoint-validation/tsconfig.json index 78398e4d..60f0e6b9 100644 --- a/libs/checkpoint-validation/tsconfig.json +++ b/libs/checkpoint-validation/tsconfig.json @@ -5,6 +5,7 @@ "rootDir": "./src", "target": "ES2021", "lib": ["ES2021", "ES2022.Object", "DOM"], + "types": ["node", "jest"], "module": "ES2020", "moduleResolution": "NodeNext", "esModuleInterop": true, diff --git a/yarn.lock b/yarn.lock index c211b52f..369c157e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1785,6 +1785,7 @@ __metadata: "@testcontainers/mongodb": ^10.13.2 "@testcontainers/postgresql": ^10.13.2 "@tsconfig/recommended": ^1.0.3 + "@types/jest": ^29.5.13 "@types/uuid": ^10 "@typescript-eslint/eslint-plugin": ^6.12.0 "@typescript-eslint/parser": ^6.12.0 @@ -3494,6 +3495,16 @@ __metadata: languageName: node linkType: hard +"@types/jest@npm:^29.5.13": + version: 29.5.13 + resolution: "@types/jest@npm:29.5.13" + dependencies: + expect: ^29.0.0 + pretty-format: ^29.0.0 + checksum: 875ac23c2398cdcf22aa56c6ba24560f11d2afda226d4fa23936322dde6202f9fdbd2b91602af51c27ecba223d9fc3c1e33c9df7e47b3bf0e2aefc6baf13ce53 + languageName: node + linkType: hard + "@types/json-schema@npm:^7.0.12": version: 7.0.15 resolution: "@types/json-schema@npm:7.0.15" @@ -6871,7 +6882,7 @@ __metadata: languageName: node linkType: hard -"expect@npm:^29.7.0": +"expect@npm:^29.0.0, expect@npm:^29.7.0": version: 29.7.0 resolution: "expect@npm:29.7.0" dependencies: @@ -10764,7 +10775,7 @@ __metadata: languageName: node linkType: hard -"pretty-format@npm:^29.7.0": +"pretty-format@npm:^29.0.0, pretty-format@npm:^29.7.0": version: 29.7.0 resolution: "pretty-format@npm:29.7.0" dependencies: