()
| 4 | import { onTestFinished } from 'vitest' |
| 5 | |
| 6 | export async function runDynamicFileESM() { |
| 7 | const fileUrl = new URL('./dynamic-file-esm.ignore.js', import.meta.url) |
| 8 | const filename = fileURLToPath(fileUrl) |
| 9 | onTestFinished(() => { |
| 10 | if(existsSync(filename)) { |
| 11 | rmSync(filename) |
| 12 | } |
| 13 | }) |
| 14 | |
| 15 | if (existsSync(filename)) { |
| 16 | rmSync(filename) |
| 17 | } |
| 18 | |
| 19 | writeFileSync(filename, ` |
| 20 | // File created by coverage/fixtures/src/dynamic-files.ts |
| 21 | export function run() { |
| 22 | return "Import works" |
| 23 | } |
| 24 | function uncovered() {} |
| 25 | `.trim(), 'utf-8') |
| 26 | |
| 27 | const { run } = await import(/* @vite-ignore */ fileUrl.href) |
| 28 | |
| 29 | if (run() !== 'Import works') { |
| 30 | throw new Error(`Failed to run ${filename}`) |
| 31 | } |
| 32 | |
| 33 | return "Done" |
| 34 | } |
| 35 | |
| 36 | export async function runDynamicFileCJS() { |
| 37 | const filename = fileURLToPath(new URL('./dynamic-file-cjs.ignore.cjs', import.meta.url)) |
no test coverage detected