fix(test): restore cli runtime mocks and gateway timeouts

This commit is contained in:
Peter Steinberger
2026-04-07 16:15:55 +01:00
parent eb29782416
commit d366b13ec9
2 changed files with 32 additions and 0 deletions

View File

@@ -54,6 +54,33 @@ const { defaultRuntime, runtimeLogs, runtimeErrors, resetRuntimeCapture } =
export { runtimeErrors, runtimeLogs };
function restoreRuntimeCaptureMocks() {
defaultRuntime.log.mockReset();
defaultRuntime.log.mockImplementation((...args: unknown[]) => {
runtimeLogs.push(args.map((value) => String(value)).join(" "));
});
defaultRuntime.error.mockReset();
defaultRuntime.error.mockImplementation((...args: unknown[]) => {
runtimeErrors.push(args.map((value) => String(value)).join(" "));
});
defaultRuntime.writeStdout.mockReset();
defaultRuntime.writeStdout.mockImplementation((value: string) => {
defaultRuntime.log(value.endsWith("\n") ? value.slice(0, -1) : value);
});
defaultRuntime.writeJson.mockReset();
defaultRuntime.writeJson.mockImplementation((value: unknown, space = 2) => {
defaultRuntime.log(JSON.stringify(value, null, space > 0 ? space : undefined));
});
defaultRuntime.exit.mockReset();
defaultRuntime.exit.mockImplementation((code: number) => {
throw new Error(`__exit__:${code}`);
});
}
vi.mock("../runtime.js", () => ({
defaultRuntime,
}));
@@ -327,6 +354,7 @@ export function runPluginsCommand(argv: string[]) {
export function resetPluginsCliTestState() {
resetRuntimeCapture();
restoreRuntimeCaptureMocks();
loadConfig.mockReset();
readConfigFileSnapshot.mockReset();
writeConfigFile.mockReset();