test: speed up default test env
This commit is contained in:
6
test/global-setup.ts
Normal file
6
test/global-setup.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { installTestEnv } from "./test-env";
|
||||
|
||||
export default async () => {
|
||||
const { cleanup } = installTestEnv();
|
||||
return () => cleanup();
|
||||
};
|
||||
@@ -9,11 +9,6 @@ import type { ClawdbotConfig } from "../src/config/config.js";
|
||||
import type { OutboundSendDeps } from "../src/infra/outbound/deliver.js";
|
||||
import { setActivePluginRegistry } from "../src/plugins/runtime.js";
|
||||
import { createTestRegistry } from "../src/test-utils/channel-plugins.js";
|
||||
import { installTestEnv } from "./test-env";
|
||||
|
||||
const { cleanup } = installTestEnv();
|
||||
process.on("exit", cleanup);
|
||||
|
||||
const pickSendFn = (id: ChannelId, deps?: OutboundSendDeps) => {
|
||||
switch (id) {
|
||||
case "discord":
|
||||
|
||||
@@ -54,6 +54,7 @@ export function installTestEnv(): { cleanup: () => void; tempHome: string } {
|
||||
}
|
||||
|
||||
const restore: RestoreEntry[] = [
|
||||
{ key: "CLAWDBOT_TEST_FAST", value: process.env.CLAWDBOT_TEST_FAST },
|
||||
{ key: "HOME", value: process.env.HOME },
|
||||
{ key: "USERPROFILE", value: process.env.USERPROFILE },
|
||||
{ key: "XDG_CONFIG_HOME", value: process.env.XDG_CONFIG_HOME },
|
||||
@@ -84,6 +85,7 @@ export function installTestEnv(): { cleanup: () => void; tempHome: string } {
|
||||
process.env.HOME = tempHome;
|
||||
process.env.USERPROFILE = tempHome;
|
||||
process.env.CLAWDBOT_TEST_HOME = tempHome;
|
||||
process.env.CLAWDBOT_TEST_FAST = "1";
|
||||
|
||||
// Ensure test runs never touch the developer's real config/state, even if they have overrides set.
|
||||
delete process.env.CLAWDBOT_CONFIG_PATH;
|
||||
|
||||
Reference in New Issue
Block a user