casefile-runner helps you test CLI-style behavior using a single .case.yaml file that contains:
- CLI args
- Virtual input files
- Expected
stdoutand/orstderr
npm install casefile-runnerargs:
- input/a.txt
input/a.txt: |
hello
stdout: |
hello
stderr: |
warning: demo stderr lineimport { executeCasefileFile } from 'casefile-runner';
const result = await executeCasefileFile('example.case.yaml', async (files, args) => {
const fileMap = new Map(files.map((item) => [item.path, item.content]));
const content = fileMap.get(args[0] ?? '') ?? '';
return {
stdout: content,
stderr: 'warning: demo stderr line\n',
exitCode: 0
};
});parseCasefile(source)parses raw YAML fixture text.loadCasefile(path)reads and parses a fixture file from disk.runCasefile(testCase, executor)runs an already-parsed case.executeCasefileFile(path, executor, options)reads, runs, and optionally updates expected output.
Pass updateExpected: true to rewrite stdout/stderr sections from actual output:
await executeCasefileFile(casePath, executor, { updateExpected: true });