Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

fix(tests): make derivedVarRegistry doc-file discovery case-exact (#3553)

Md Shahrier Islam Arhamf5b7cb17eeea
diff --git a/packages/core/src/theme/derivedVarRegistry.test.ts b/packages/core/src/theme/derivedVarRegistry.test.ts
index f323bd9d86..df76e741b2 100644
--- a/packages/core/src/theme/derivedVarRegistry.test.ts
+++ b/packages/core/src/theme/derivedVarRegistry.test.ts
@@ -14,7 +14,7 @@
import {describe, it, expect} from 'vitest';
import {derivedVarRegistry, getDerivedVars} from './derivedVarRegistry';
-import {readdirSync, readFileSync, existsSync} from 'fs';
+import {readdirSync, readFileSync} from 'fs';
import {join} from 'path';
const SRC_DIR = join(__dirname, '..');
@@ -129,8 +129,9 @@ function discoverComponents(): ComponentInfo[] {
for (const dir of dirs) {
const dirPath = join(SRC_DIR, dir);
+ const dirEntries = readdirSync(dirPath);
// Find source files with component vars (.tsx and .ts, excluding tests/docs)
- const sourceFiles = readdirSync(dirPath)
+ const sourceFiles = dirEntries
.filter(
f =>
(f.endsWith('.tsx') || f.endsWith('.ts')) &&
@@ -150,11 +151,15 @@ function discoverComponents(): ComponentInfo[] {
continue;
}
- // Only check component directories (those with a doc file)
- const docPath = join(dirPath, `${dir}.doc.mjs`);
- if (!existsSync(docPath)) {
+ // Only check component directories (those with a doc file named after the
+ // directory). Match against the on-disk listing rather than existsSync so
+ // the comparison is case-exact everywhere — on case-insensitive
+ // filesystems (macOS, Windows) existsSync('theme/theme.doc.mjs') matches
+ // theme/Theme.doc.mjs and pulls in a directory that CI never checks.
+ if (!dirEntries.includes(`${dir}.doc.mjs`)) {
continue;
}
+ const docPath = join(dirPath, `${dir}.doc.mjs`);
let docVars: string[] = [];
let docDerived: DerivedDocEntry[] = [];