Skip to content

Commit f569ee4

Browse files
test: stabilize node 18 suite
1 parent fee75b8 commit f569ee4

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

node/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"demo:anthropic": "tsx --env-file-if-exists=.env examples/anthropic-demo.ts",
4343
"lint": "eslint .",
4444
"prepublishOnly": "npm test && npm run build",
45-
"test": "tsx --test tests/*.test.ts",
45+
"test": "node scripts/run-tests.mjs",
4646
"typecheck": "tsc --noEmit",
4747
"test:package": "npm run build && node scripts/package-smoke.mjs",
4848
"test:coverage": "tsx --test --experimental-test-coverage --test-coverage-exclude='tests/**' --test-coverage-lines=100 --test-coverage-functions=100 --test-coverage-branches=95 tests/*.test.ts"

node/scripts/run-tests.mjs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { spawnSync } from 'node:child_process';
2+
import { readdirSync } from 'node:fs';
3+
import { createRequire } from 'node:module';
4+
import { fileURLToPath } from 'node:url';
5+
6+
const require = createRequire(import.meta.url);
7+
const tsxCli = require.resolve('tsx/cli');
8+
const testsDirectory = new URL('../tests/', import.meta.url);
9+
const testFiles = readdirSync(testsDirectory)
10+
.filter((file) => file.endsWith('.test.ts'))
11+
.sort();
12+
13+
for (const testFile of testFiles) {
14+
const result = spawnSync(
15+
process.execPath,
16+
[tsxCli, '--test', fileURLToPath(new URL(testFile, testsDirectory))],
17+
{ stdio: 'inherit' },
18+
);
19+
20+
if (result.status !== 0) {
21+
process.exit(result.status ?? 1);
22+
}
23+
}

0 commit comments

Comments
 (0)