feat(watch mode): Add watch mode support with CLI options and enhanced documentation

This commit is contained in:
2025-05-26 04:37:38 +00:00
parent 7aaeed0dc6
commit 82757c4abc
12 changed files with 336 additions and 9 deletions

View File

@@ -16,6 +16,8 @@ export const runCli = async () => {
let startFromFile: number | null = null;
let stopAtFile: number | null = null;
let timeoutSeconds: number | null = null;
let watchMode: boolean = false;
let watchIgnorePatterns: string[] = [];
// Parse options
for (let i = 0; i < args.length; i++) {
@@ -84,6 +86,18 @@ export const runCli = async () => {
process.exit(1);
}
break;
case '--watch':
case '-w':
watchMode = true;
break;
case '--watch-ignore':
if (i + 1 < args.length) {
watchIgnorePatterns = args[++i].split(',');
} else {
console.error('Error: --watch-ignore requires a comma-separated list of patterns');
process.exit(1);
}
break;
default:
if (!arg.startsWith('-')) {
testPath = arg;
@@ -110,6 +124,8 @@ export const runCli = async () => {
console.error(' --startFrom <n> Start running from test file number n');
console.error(' --stopAt <n> Stop running at test file number n');
console.error(' --timeout <s> Timeout test files after s seconds');
console.error(' --watch, -w Watch for file changes and re-run tests');
console.error(' --watch-ignore Patterns to ignore in watch mode (comma-separated)');
process.exit(1);
}
@@ -125,7 +141,12 @@ export const runCli = async () => {
}
const tsTestInstance = new TsTest(process.cwd(), testPath, executionMode, logOptions, tags, startFromFile, stopAtFile, timeoutSeconds);
await tsTestInstance.run();
if (watchMode) {
await tsTestInstance.runWatch(watchIgnorePatterns);
} else {
await tsTestInstance.run();
}
};
// Execute CLI when this file is run directly