* Assertions happen here
(t: T, p: FsProject, entrypoints: Entrypoint[])
| 744 | * Assertions happen here |
| 745 | */ |
| 746 | async function execute(t: T, p: FsProject, entrypoints: Entrypoint[]) { |
| 747 | // |
| 748 | // Install ts-node and try to import all the index-* files |
| 749 | // |
| 750 | |
| 751 | const service = t.context.tsNodeUnderTest.register({ |
| 752 | projectSearchDir: p.cwd, |
| 753 | }); |
| 754 | process.__test_setloader__(t.context.tsNodeUnderTest.createEsmHooks(service)); |
| 755 | |
| 756 | for (const entrypoint of entrypoints) { |
| 757 | t.log(`Importing ${join(p.cwd, entrypoint)}`); |
| 758 | try { |
| 759 | const { result } = await dynamicImport( |
| 760 | pathToFileURL(join(p.cwd, entrypoint)) |
| 761 | ); |
| 762 | expect(result).toBeInstanceOf(Promise); |
| 763 | expect(result.mark).toBe('marked'); |
| 764 | const testsRun = await result; |
| 765 | t.log(`Entrypoint ran ${testsRun} tests.`); |
| 766 | } catch (e) { |
| 767 | try { |
| 768 | const launchJsonPath = Path.resolve( |
| 769 | __dirname, |
| 770 | '../../.vscode/launch.json' |
| 771 | ); |
| 772 | const launchJson = JSON.parse(fs.readFileSync(launchJsonPath, 'utf8')); |
| 773 | const config = launchJson.configurations.find( |
| 774 | (c: any) => c.name === 'Debug resolver test' |
| 775 | ); |
| 776 | config.cwd = Path.join( |
| 777 | '${workspaceFolder}', |
| 778 | Path.relative(Path.resolve(__dirname, '../..'), p.cwd) |
| 779 | ); |
| 780 | config.program = `./${entrypoint}`; |
| 781 | fs.writeFileSync(launchJsonPath, JSON.stringify(launchJson, null, 2)); |
| 782 | } catch {} |
| 783 | throw new Error( |
| 784 | [ |
| 785 | (e as Error).message, |
| 786 | (e as Error).stack, |
| 787 | '', |
| 788 | 'This is an error in a resolver test. It might be easier to investigate by running outside of the test suite.', |
| 789 | 'To do that, try pasting this into your bash shell (windows invocation will be similar but maybe not identical):', |
| 790 | ` ( cd ${p.cwd} ; node --loader ../../../esm.mjs ./${entrypoint} )`, |
| 791 | ].join('\n') |
| 792 | ); |
| 793 | } |
| 794 | } |
| 795 | } |
| 796 | |
| 797 | function fileInfo(filename: string, typeModule: boolean, allowJs: boolean) { |
| 798 | const ext = filename.match(/\.(.*)$/)?.[1] ?? filename; |
no test coverage detected
searching dependent graphs…