@@ -27381,6 +27381,8 @@ class MarkdownDocsGenerator {
2738127381 let inComment = false;
2738227382 let commentLines = [];
2738327383 let braceLevel = 0;
27384+ let inDynamicTestBlock = false;
27385+ let dynamicTestTemplate = '';
2738427386 for (let i = 0; i < lines.length; i++) {
2738527387 const line = lines[i].trim();
2738627388 const lineNumber = i + 1;
@@ -27417,9 +27419,39 @@ class MarkdownDocsGenerator {
2741727419 };
2741827420 continue;
2741927421 }
27420- // Extract test cases (it, test, bench) including Vitest modifiers
27421- const testMatch = line.match(/(?:it|test|bench)(?:\.(?:skip|only|todo|concurrent|each\([^)]*\)))?\s*\(\s*['"`]([^'"`]+)['"`]/);
27422- if (testMatch && currentDescribe) {
27422+ // Check for dynamic test patterns (forEach, map, etc.)
27423+ const dynamicTestMatch = line.match(/\.forEach\s*\(\s*\([^)]*\)\s*=>\s*\{/);
27424+ if (dynamicTestMatch && currentDescribe) {
27425+ inDynamicTestBlock = true;
27426+ // Look ahead to find the test template
27427+ for (let j = i + 1; j < Math.min(i + 10, lines.length); j++) {
27428+ const testTemplateMatch = lines[j].match(/(?:it|test|bench)(?:\.(?:skip|only|todo|concurrent|each\([^)]*\)))?\s*\(\s*[`'"]([^`'"]*)[`'"]/);
27429+ if (testTemplateMatch) {
27430+ dynamicTestTemplate = testTemplateMatch[1];
27431+ const description = commentLines.length > 0 ? this.parseTestDescription(commentLines) : 'Dynamic test generated from forEach loop';
27432+ const link = this.generateTestLink(filePath, lineNumber, currentDescribe.name, dynamicTestTemplate);
27433+ tests.push({
27434+ testName: `${currentDescribe.name} > ${dynamicTestTemplate} (dynamic)`,
27435+ shortName: `${dynamicTestTemplate} (dynamic)`,
27436+ describeName: currentDescribe.name,
27437+ link,
27438+ description,
27439+ lineNumber,
27440+ tags: this.extractTags(currentDescribe.name, description).concat(['dynamic'])
27441+ });
27442+ if (this.verbose) {
27443+ console.log(` Found dynamic test pattern: ${dynamicTestTemplate}`);
27444+ }
27445+ break;
27446+ }
27447+ }
27448+ // Reset comment lines after processing
27449+ commentLines = [];
27450+ continue;
27451+ }
27452+ // Extract regular test cases (it, test, bench) with template literal support
27453+ const testMatch = line.match(/(?:it|test|bench)(?:\.(?:skip|only|todo|concurrent|each\([^)]*\)))?\s*\(\s*[`'"]([^`'"]*)[`'"]/);
27454+ if (testMatch && currentDescribe && !inDynamicTestBlock) {
2742327455 const testName = testMatch[1];
2742427456 const fullTestName = `${currentDescribe.name} > ${testName}`;
2742527457 const description = this.parseTestDescription(commentLines);
@@ -27440,6 +27472,7 @@ class MarkdownDocsGenerator {
2744027472 // Reset scope tracking when leaving blocks
2744127473 if (currentDescribe && braceLevel < currentDescribe.level) {
2744227474 currentDescribe = null;
27475+ inDynamicTestBlock = false;
2744327476 }
2744427477 }
2744527478 return tests;
0 commit comments