Files
openclaw/vitest.unit-paths.mjs
2026-03-18 12:16:07 -07:00

47 lines
1.2 KiB
JavaScript

import path from "node:path";
export const unitTestIncludePatterns = [
"src/**/*.test.ts",
"test/**/*.test.ts",
"ui/src/ui/app-chat.test.ts",
"ui/src/ui/views/agents-utils.test.ts",
"ui/src/ui/views/chat.test.ts",
"ui/src/ui/views/usage-render-details.test.ts",
"ui/src/ui/controllers/agents.test.ts",
"ui/src/ui/controllers/chat.test.ts",
];
export const unitTestAdditionalExcludePatterns = [
"src/gateway/**",
"extensions/**",
"src/browser/**",
"src/line/**",
"src/agents/**",
"src/auto-reply/**",
"src/commands/**",
];
const sharedBaseExcludePatterns = [
"dist/**",
"apps/macos/**",
"apps/macos/.build/**",
"**/node_modules/**",
"**/vendor/**",
"dist/OpenClaw.app/**",
"**/*.live.test.ts",
"**/*.e2e.test.ts",
];
const normalizeRepoPath = (value) => value.split(path.sep).join("/");
const matchesAny = (file, patterns) => patterns.some((pattern) => path.matchesGlob(file, pattern));
export function isUnitConfigTestFile(file) {
const normalizedFile = normalizeRepoPath(file);
return (
matchesAny(normalizedFile, unitTestIncludePatterns) &&
!matchesAny(normalizedFile, sharedBaseExcludePatterns) &&
!matchesAny(normalizedFile, unitTestAdditionalExcludePatterns)
);
}