mirror of
https://github.com/n8n-io/n8n.git
synced 2026-06-02 09:47:00 +02:00
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>
25 lines
781 B
TypeScript
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)));
|
|
}
|