mirror of
https://github.com/moltbot/moltbot.git
synced 2026-05-13 15:47:28 +00:00
test: trim test startup overhead
This commit is contained in:
@@ -1,14 +1,13 @@
|
||||
import { execFileSync } from "node:child_process";
|
||||
import { readFileSync } from "node:fs";
|
||||
import path from "node:path";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
collectPluginExtensionImportBoundaryInventory,
|
||||
diffInventory,
|
||||
main,
|
||||
} from "../scripts/check-plugin-extension-import-boundary.mjs";
|
||||
|
||||
const repoRoot = process.cwd();
|
||||
const scriptPath = path.join(repoRoot, "scripts", "check-plugin-extension-import-boundary.mjs");
|
||||
const baselinePath = path.join(
|
||||
repoRoot,
|
||||
"test",
|
||||
@@ -20,6 +19,27 @@ function readBaseline() {
|
||||
return JSON.parse(readFileSync(baselinePath, "utf8"));
|
||||
}
|
||||
|
||||
function createCapturedIo() {
|
||||
let stdout = "";
|
||||
let stderr = "";
|
||||
return {
|
||||
io: {
|
||||
stdout: {
|
||||
write(chunk) {
|
||||
stdout += String(chunk);
|
||||
},
|
||||
},
|
||||
stderr: {
|
||||
write(chunk) {
|
||||
stderr += String(chunk);
|
||||
},
|
||||
},
|
||||
},
|
||||
readStdout: () => stdout,
|
||||
readStderr: () => stderr,
|
||||
};
|
||||
}
|
||||
|
||||
describe("plugin extension import boundary inventory", () => {
|
||||
it("keeps dedicated web-search registry shims out of the remaining inventory", async () => {
|
||||
const inventory = await collectPluginExtensionImportBoundaryInventory();
|
||||
@@ -65,12 +85,12 @@ describe("plugin extension import boundary inventory", () => {
|
||||
expect(diffInventory(expected, actual)).toEqual({ missing: [], unexpected: [] });
|
||||
});
|
||||
|
||||
it("script json output matches the baseline exactly", () => {
|
||||
const stdout = execFileSync(process.execPath, [scriptPath, "--json"], {
|
||||
cwd: repoRoot,
|
||||
encoding: "utf8",
|
||||
});
|
||||
it("script json output matches the baseline exactly", async () => {
|
||||
const captured = createCapturedIo();
|
||||
const exitCode = await main(["--json"], captured.io);
|
||||
|
||||
expect(JSON.parse(stdout)).toEqual(readBaseline());
|
||||
expect(exitCode).toBe(0);
|
||||
expect(captured.readStderr()).toBe("");
|
||||
expect(JSON.parse(captured.readStdout())).toEqual(readBaseline());
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user