test(tooling): remove helper replays (#122790)

* test(tooling): remove helper replays

* refactor(tooling): inline fixture json serialization
This commit is contained in:
Peter Steinberger
2026-08-12 13:31:23 -07:00
committed by GitHub
parent e1b8150a06
commit 7595d6f432
3 changed files with 1 additions and 75 deletions
+1 -2
View File
@@ -2,14 +2,13 @@
import fs from "node:fs";
import path from "node:path";
export const json = (value) => `${JSON.stringify(value, null, 2)}\n`;
export const readJson = (file) => JSON.parse(fs.readFileSync(file, "utf8"));
export const write = (file, contents) => {
fs.mkdirSync(path.dirname(file), { recursive: true });
fs.writeFileSync(file, contents);
};
export const writeJson = (file, value) => write(file, json(value));
export const writeJson = (file, value) => write(file, `${JSON.stringify(value, null, 2)}\n`);
export const requireArg = (value, name) => {
if (!value) {
-44
View File
@@ -1,44 +0,0 @@
// Fixture Common tests cover shared E2E fixture file/assertion helpers.
import { readFileSync } from "node:fs";
import path from "node:path";
import { afterEach, describe, expect, it } from "vitest";
import {
assert,
json,
readJson,
requireArg,
write,
writeJson,
} from "../../scripts/e2e/lib/fixtures/common.mjs";
import { cleanupTempDirs, makeTempDir } from "../helpers/temp-dir.js";
const tempDirs: string[] = [];
afterEach(() => {
cleanupTempDirs(tempDirs);
});
describe("fixture common helpers", () => {
it("writes nested text and formatted JSON files", () => {
const root = makeTempDir(tempDirs, "openclaw-fixture-common-");
const textPath = path.join(root, "nested", "fixture.txt");
const jsonPath = path.join(root, "config", "fixture.json");
write(textPath, "contents");
writeJson(jsonPath, { enabled: true, nested: { value: 1 } });
expect(readFileSync(textPath, "utf8")).toBe("contents");
expect(readFileSync(jsonPath, "utf8")).toBe(
`${JSON.stringify({ enabled: true, nested: { value: 1 } }, null, 2)}\n`,
);
expect(readJson(jsonPath)).toEqual({ enabled: true, nested: { value: 1 } });
expect(json({ ok: true })).toBe(`${JSON.stringify({ ok: true }, null, 2)}\n`);
});
it("rejects missing required arguments and failed assertions", () => {
expect(requireArg("value", "field")).toBe("value");
expect(() => requireArg("", "field")).toThrow("field is required");
expect(() => assert(false, "fixture failed")).toThrow("fixture failed");
expect(() => assert(true, "fixture failed")).not.toThrow();
});
});
-29
View File
@@ -3357,35 +3357,6 @@ describe("scripts/test-projects full-suite sharding", () => {
});
describe("scripts/test-projects parallel cache paths", () => {
it("assigns isolated Vitest fs-module cache paths per parallel shard", () => {
const specs = applyParallelVitestCachePaths(
[
{ config: "test/vitest/vitest.gateway.config.ts", env: {}, pnpmArgs: [] },
{ config: "test/vitest/vitest.extension-matrix.config.ts", env: {}, pnpmArgs: [] },
],
{ cwd: "/repo", env: {} },
);
expect(specs.map((spec) => spec.env)).toEqual([
{
OPENCLAW_VITEST_FS_MODULE_CACHE_PATH: path.join(
"/repo",
"node_modules",
".experimental-vitest-cache",
"0-test-vitest-vitest.gateway.config.ts",
),
},
{
OPENCLAW_VITEST_FS_MODULE_CACHE_PATH: path.join(
"/repo",
"node_modules",
".experimental-vitest-cache",
"1-test-vitest-vitest.extension-matrix.config.ts",
),
},
]);
});
it("splits an explicit global cache root per parallel shard", () => {
const specs = applyParallelVitestCachePaths(
[