Skip to content

Graphs that teach > graphs that impress. Turn any code into an interactive knowledge graph you can explore, search, and ask questions about. Works with Claude Code, Codex, Cursor, Copilot, Gemini CLI, and more.

fix(tests): derive built-in config counts from filesystem instead of hardcoding

Lum110442f220d3cd87
diff --git a/understand-anything-plugin/packages/core/src/__tests__/config-schema.test.ts b/understand-anything-plugin/packages/core/src/__tests__/config-schema.test.ts
index c1cf5893..2d7d7809 100644
--- a/understand-anything-plugin/packages/core/src/__tests__/config-schema.test.ts
+++ b/understand-anything-plugin/packages/core/src/__tests__/config-schema.test.ts
@@ -1,3 +1,5 @@
+import { readdirSync } from "node:fs";
+import { fileURLToPath } from "node:url";
import { describe, it, expect } from "vitest";
import {
TreeSitterConfigSchema,
@@ -9,6 +11,14 @@ import {
import { builtinLanguageConfigs } from "../languages/configs/index.js";
import { builtinFrameworkConfigs } from "../languages/frameworks/index.js";
+/** Count config modules (one config per file, index.ts excluded) in a directory. */
+function countConfigModules(relativeDir: string): number {
+ const dir = fileURLToPath(new URL(relativeDir, import.meta.url));
+ return readdirSync(dir).filter(
+ (file) => file.endsWith(".ts") && file !== "index.ts"
+ ).length;
+}
+
// =============================================================================
// Schema type-level tests
// =============================================================================
@@ -322,8 +332,10 @@ describe("Built-in Language Configs", () => {
"json-schema",
]);
- it("has the expected total number of built-in configs", () => {
- expect(builtinLanguageConfigs).toHaveLength(41);
+ it("registers every config module in the configs directory", () => {
+ expect(builtinLanguageConfigs).toHaveLength(
+ countConfigModules("../languages/configs/")
+ );
});
it("every config passes base LanguageConfigSchema validation", () => {
@@ -421,8 +433,10 @@ describe("Built-in Language Configs", () => {
// =============================================================================
describe("Built-in Framework Configs", () => {
- it("has the expected total number of built-in framework configs", () => {
- expect(builtinFrameworkConfigs).toHaveLength(10);
+ it("registers every framework module in the frameworks directory", () => {
+ expect(builtinFrameworkConfigs).toHaveLength(
+ countConfigModules("../languages/frameworks/")
+ );
});
it("every framework config passes FrameworkConfigSchema validation", () => {