n8n/packages/@n8n/instance-ai/evaluations/data/workflows/index.ts
José Braulio González Valido 2383749980
feat(ai-builder): Workflow evaluation framework with LLM mock execution (#27818)
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: Arvin A <51036481+DeveloperTheExplorer@users.noreply.github.com>
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
2026-04-07 13:31:16 +00:00

25 lines
781 B
TypeScript

import { readFileSync, readdirSync } from 'fs';
import { join } from 'path';
import type { WorkflowTestCase } from '../../types';
function parseTestCaseFile(filePath: string): WorkflowTestCase {
const content = readFileSync(filePath, 'utf-8');
try {
return JSON.parse(content) as WorkflowTestCase;
} catch (error) {
throw new Error(
`Failed to parse test case ${filePath}: ${error instanceof Error ? error.message : String(error)}`,
);
}
}
export function loadWorkflowTestCases(filter?: string): WorkflowTestCase[] {
const dir = __dirname;
let files = readdirSync(dir).filter((f) => f.endsWith('.json'));
if (filter) {
files = files.filter((f) => f.toLowerCase().includes(filter.toLowerCase()));
}
return files.map((f) => parseTestCaseFile(join(dir, f)));
}