Skip to content

Commit 63cd603

Browse files
committed
test: use npx ts-node for CLI integration tests
1 parent 1de00ca commit 63cd603

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
"openai": "^4.74.0",
5151
"@anthropic-ai/sdk": "^0.32.1",
5252
"cohere-ai": "^7.15.0",
53+
"ts-node": "^10.9.2",
5354
"jsonschema": "^1.4.1",
5455
"@types/cli-progress": "^3.11.6",
5556
"@types/lodash": "4.14.74",

tests/custom/integration/cli.test.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,17 @@ async function runCli(
1919
): Promise<{ stdout: string; stderr: string; exitCode: number }> {
2020
return new Promise((resolve) => {
2121
const packageRoot = path.resolve(__dirname, "../../../");
22-
// NB: cli.js must be compiled before running this test
23-
// This is fine in CI, since we compile before running tests
24-
const cliPath = path.join(packageRoot, "dist/cli.js");
22+
// Use ts-node to run the TypeScript source directly
23+
const cliPath = path.join(packageRoot, "src/cli.ts");
2524

26-
// Use spawn to avoid shell interpretation issues
27-
const childProcess = spawn("node", [cliPath, ...args], {
25+
// Use spawn with ts-node to execute the TypeScript file
26+
const childProcess = spawn("npx", ["ts-node", cliPath, ...args], {
2827
stdio: ["ignore", "pipe", "pipe"],
28+
// Ensure we use the project's ts-node and typescript
29+
env: {
30+
...process.env,
31+
PATH: `${packageRoot}/node_modules/.bin:${process.env.PATH}`,
32+
},
2933
});
3034

3135
let stdout = "";

0 commit comments

Comments
 (0)