Skip to content

Commit a34015f

Browse files
again
1 parent 88db33f commit a34015f

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

packages/cli/src/__tests__/cli.test.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,16 @@ import fs from 'fs-extra';
33
import path from 'path';
44
import { getId } from '@walkeros/core';
55

6+
// Resolve paths relative to the cli package root (two levels up from __tests__)
7+
// so the test works regardless of Jest's cwd.
8+
const pkgRoot = path.resolve(__dirname, '..', '..');
9+
610
describe('CLI Bundle Command', () => {
7-
const testOutputDir = path.join('.tmp', `cli-${Date.now()}-${getId()}`);
11+
const testOutputDir = path.join(
12+
pkgRoot,
13+
'.tmp',
14+
`cli-${Date.now()}-${getId()}`,
15+
);
816
const testConfigPath = path.join(testOutputDir, 'test.config.json');
917

1018
beforeEach(async () => {
@@ -24,10 +32,15 @@ describe('CLI Bundle Command', () => {
2432
args: string[],
2533
): Promise<{ stdout: string; stderr: string; exitCode: number }> => {
2634
return new Promise((resolve) => {
27-
const child = spawn('node', ['dist/index.js', ...args], {
28-
stdio: 'pipe',
29-
shell: false,
30-
});
35+
const child = spawn(
36+
'node',
37+
[path.join(pkgRoot, 'dist/index.js'), ...args],
38+
{
39+
stdio: 'pipe',
40+
shell: false,
41+
cwd: pkgRoot,
42+
},
43+
);
3144

3245
let stdout = '';
3346
let stderr = '';

0 commit comments

Comments
 (0)