Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/lib/onboard-session.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,21 @@ import os from "node:os";
import path from "node:path";
import { createRequire } from "node:module";

const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-onboard-session-"));
const require = createRequire(import.meta.url);
// Clear both the shim and the dist module so HOME changes take effect.
const shimPath = require.resolve("../../bin/lib/onboard-session");
const distPath = require.resolve("../../dist/lib/onboard-session");
const originalHome = process.env.HOME;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let session: any;
let tmpDir: string;

beforeEach(() => {
// Recreate tmpDir per test so lock artifacts (and any other on-disk state)
// from a previous test cannot leak into this one. Without this, malformed
// lock files left behind by releaseOnboardLock() make lock tests
// order-dependent. See issue #1284.
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-onboard-session-"));
process.env.HOME = tmpDir;
delete require.cache[shimPath];
delete require.cache[distPath];
Expand All @@ -28,6 +33,7 @@ beforeEach(() => {
afterEach(() => {
delete require.cache[shimPath];
delete require.cache[distPath];
fs.rmSync(tmpDir, { recursive: true, force: true });
if (originalHome === undefined) {
delete process.env.HOME;
} else {
Expand Down
Loading