@@ -3,6 +3,10 @@ import path from "node:path";
|
3 | 3 | import { describe, expect, it } from "vitest"; |
4 | 4 | import { createOpenClawTestState, withOpenClawTestState } from "./openclaw-test-state.js"; |
5 | 5 | |
| 6 | +async function expectPathMissing(targetPath: string): Promise<void> { |
| 7 | +await expect(fs.stat(targetPath)).rejects.toMatchObject({ code: "ENOENT" }); |
| 8 | +} |
| 9 | + |
6 | 10 | describe("openclaw test state", () => { |
7 | 11 | it("creates an isolated home layout with spawn env and restores process env", async () => { |
8 | 12 | const previousHome = process.env.HOME; |
@@ -35,7 +39,7 @@ describe("openclaw test state", () => {
|
35 | 39 | expect(process.env.OPENCLAW_HOME).toBe(previousOpenClawHome); |
36 | 40 | expect(process.env.OPENCLAW_STATE_DIR).toBe(previousStateDir); |
37 | 41 | expect(process.env.OPENCLAW_CONFIG_PATH).toBe(previousConfigPath); |
38 | | -await expect(fs.stat(state.root)).rejects.toThrow(); |
| 42 | +await expectPathMissing(state.root); |
39 | 43 | }); |
40 | 44 | |
41 | 45 | it("supports state-only layout without overriding HOME", async () => { |
@@ -51,7 +55,7 @@ describe("openclaw test state", () => {
|
51 | 55 | expect(process.env.OPENCLAW_STATE_DIR).toBe(state.stateDir); |
52 | 56 | expect(process.env.OPENCLAW_CONFIG_PATH).toBe(state.configPath); |
53 | 57 | expect(state.env.HOME).toBe(previousHome); |
54 | | -await expect(fs.stat(state.configPath)).rejects.toThrow(); |
| 58 | +await expectPathMissing(state.configPath); |
55 | 59 | }, |
56 | 60 | ); |
57 | 61 | }); |
|