-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
57 lines (47 loc) · 1.38 KB
/
test.js
File metadata and controls
57 lines (47 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env node
import { readdir } from "fs/promises";
import { join, extname } from "path";
import { execSync } from "child_process";
const examplesDir = "examples";
const schemaFile = "schema.json";
async function runTests() {
console.log("🧪 Running validation tests...\n");
try {
const files = await readdir(examplesDir);
const jsonFiles = files.filter((file) => extname(file) === ".json");
if (jsonFiles.length === 0) {
console.log("⚠️ No JSON files found in examples directory");
process.exit(1);
}
let passed = 0;
let failed = 0;
for (const file of jsonFiles) {
const filePath = join(examplesDir, file);
process.stdout.write(`Testing ${file}... `);
try {
execSync(`node validate.js ${schemaFile} ${filePath}`, {
stdio: "pipe",
encoding: "utf8",
});
console.log("✅ PASSED");
passed++;
} catch (error) {
console.log("❌ FAILED");
console.log(error.stdout || error.message);
failed++;
}
}
console.log("\n" + "=".repeat(50));
console.log(
`Total: ${jsonFiles.length} | Passed: ${passed} | Failed: ${failed}`,
);
console.log("=".repeat(50));
if (failed > 0) {
process.exit(1);
}
} catch (error) {
console.error("Error running tests:", error.message);
process.exit(1);
}
}
runTests();