(block: string, prefix: string)
| 609 | }; |
| 610 | |
| 611 | const prepareTestResultsFromBlock = (block: string, prefix: string): void => { |
| 612 | const name = prefix + ' - ' + (block.match(/(?<=^).*?(?=\n)/) ?? ''); |
| 613 | let count = 1; |
| 614 | let suffixedName = name; |
| 615 | while (resultsByName[suffixedName] != null) { |
| 616 | suffixedName = name + ' ' + ++count; |
| 617 | } |
| 618 | |
| 619 | const codeBlocks = parseCodeBlocks(block); |
| 620 | const hasSvelteBlocks = codeBlocks.some(({lang}) => lang == 'svelte'); |
| 621 | const hasNamedFiles = codeBlocks.some(({file}) => file != null); |
| 622 | if (hasSvelteBlocks || hasNamedFiles) { |
| 623 | const files: {[path: string]: string} = {}; |
| 624 | const scriptBlocks: {content: string; lang: string}[] = []; |
| 625 | let inSolidSource = false; |
| 626 | codeBlocks.forEach(({content, file, info, lang}) => { |
| 627 | if ( |
| 628 | content == '' || |
| 629 | info.includes('ignore') || |
| 630 | (!isBun && info.includes(' bun')) |
| 631 | ) { |
| 632 | return; |
| 633 | } |
| 634 | inSolidSource = isSolidSource(content) |
| 635 | ? true |
| 636 | : isOtherUiSource(content) |
| 637 | ? false |
| 638 | : inSolidSource; |
| 639 | if (file != null) { |
| 640 | files[resolve('/', file)] = SCRIPT_BLOCK.test(extname(file).slice(1)) |
| 641 | ? replaceSvelteImports(content) |
| 642 | : content; |
| 643 | } else if (lang == 'svelte') { |
| 644 | files['/App.svelte'] = content; |
| 645 | } else if (SCRIPT_BLOCK.test(lang)) { |
| 646 | const isSolidJsx = lang.endsWith('x') && inSolidSource; |
| 647 | scriptBlocks.push({ |
| 648 | content: replaceSvelteImports( |
| 649 | isSolidJsx |
| 650 | ? transformSolidJsx( |
| 651 | prepareRunnableCode(content, false), |
| 652 | lang as 'jsx' | 'tsx', |
| 653 | ) |
| 654 | : content, |
| 655 | ), |
| 656 | lang: isSolidJsx ? 'js' : lang, |
| 657 | }); |
| 658 | } |
| 659 | }); |
| 660 | if (scriptBlocks.length == 0) { |
| 661 | return; |
| 662 | } |
| 663 | const entryPath = |
| 664 | Object.keys(files).find((path) => |
| 665 | SCRIPT_BLOCK.test(extname(path).slice(1)), |
| 666 | ) ?? |
| 667 | (scriptBlocks.some(({lang}) => lang.endsWith('x')) |
| 668 | ? '/index.tsx' |
no test coverage detected
searching dependent graphs…