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: 23 additions & 7 deletions typescript-sdk/scripts/template-tests.mjs
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
import { existsSync, readdirSync } from "node:fs";
import { join } from "node:path";
import { spawnSync } from "node:child_process";

const suites = [
"runtime/tests/*.test.mjs",
"typescript-sdk/tests/*.test.mjs"
];
const root = new URL("../..", import.meta.url);

for (const pattern of suites) {
const run = spawnSync("node", ["--test", pattern], {
const suites = ["runtime/tests", "typescript-sdk/tests"];

const findTestFiles = (dir) => {
if (!existsSync(new URL(dir, root))) {
return [];
}

return readdirSync(new URL(dir, root))
.filter((name) => name.endsWith(".test.mjs"))
.map((name) => join(dir, name));
};

for (const suiteDir of suites) {
const files = findTestFiles(suiteDir);
if (files.length === 0) {
continue;
}

const run = spawnSync("node", ["--test", ...files], {
stdio: "inherit",
cwd: new URL("../..", import.meta.url)
cwd: root
});
if (run.status !== 0) {
process.exit(run.status ?? 1);
Expand Down
Loading