Skip to content
Closed
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
30 changes: 25 additions & 5 deletions typescript-sdk/scripts/template-tests.mjs
Original file line number Diff line number Diff line change
@@ -1,15 +1,35 @@
import { spawnSync } from "node:child_process";
import { existsSync, readdirSync } from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";

const repoRoot = fileURLToPath(new URL("../..", import.meta.url));

const suites = [
"runtime/tests/*.test.mjs",
"typescript-sdk/tests/*.test.mjs"
"runtime/tests",
"typescript-sdk/tests"
];

for (const pattern of suites) {
const run = spawnSync("node", ["--test", pattern], {
for (const suiteDir of suites) {
const absoluteSuiteDir = path.join(repoRoot, suiteDir);

if (!existsSync(absoluteSuiteDir)) {
continue;
}

const matchedFiles = readdirSync(absoluteSuiteDir)
.filter((fileName) => fileName.endsWith(".test.mjs"))
.map((fileName) => path.join(suiteDir, fileName));

if (matchedFiles.length === 0) {
continue;
}

const run = spawnSync("node", ["--test", ...matchedFiles], {
stdio: "inherit",
cwd: new URL("../..", import.meta.url)
cwd: repoRoot
});

if (run.status !== 0) {
process.exit(run.status ?? 1);
}
Expand Down
Loading