Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

test(sources-set): restore process.exit after each test, not the last test's stub

garrytan72e07c7a23cf
diff --git a/test/sources-set-cr-mode.test.ts b/test/sources-set-cr-mode.test.ts
index f7534434e5..6797f8d794 100644
--- a/test/sources-set-cr-mode.test.ts
+++ b/test/sources-set-cr-mode.test.ts
@@ -11,7 +11,7 @@
* - Missing arguments → exit code 2 with usage
*/
-import { afterAll, beforeAll, beforeEach, describe, expect, test } from 'bun:test';
+import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, test } from 'bun:test';
import { PGLiteEngine } from '../src/core/pglite-engine.ts';
import { resetPgliteState } from './helpers/reset-pglite.ts';
import { runSources } from '../src/commands/sources.ts';
@@ -29,9 +29,10 @@ describe('gbrain sources set-cr-mode', () => {
afterAll(async () => {
await engine.disconnect();
- process.exit = origExit;
});
+ afterEach(() => { process.exit = origExit; });
+
beforeEach(async () => {
await resetPgliteState(engine);
exitCode = null;
diff --git a/test/sources-set-path.test.ts b/test/sources-set-path.test.ts
index 04ee6c8678..897554a886 100644
--- a/test/sources-set-path.test.ts
+++ b/test/sources-set-path.test.ts
@@ -15,7 +15,7 @@
* same process.exit stub).
*/
-import { afterAll, beforeAll, beforeEach, describe, expect, test } from 'bun:test';
+import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, test } from 'bun:test';
import { mkdirSync, mkdtempSync, rmSync, symlinkSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
@@ -43,10 +43,11 @@ describe('gbrain sources set-path', () => {
afterAll(async () => {
await engine.disconnect();
- process.exit = origExit;
for (const d of tmpDirs) rmSync(d, { recursive: true, force: true });
});
+ afterEach(() => { process.exit = origExit; });
+
beforeEach(async () => {
await resetPgliteState(engine);
exitCode = null;