()
| 34 | } |
| 35 | |
| 36 | export async function runDynamicFileCJS() { |
| 37 | const filename = fileURLToPath(new URL('./dynamic-file-cjs.ignore.cjs', import.meta.url)) |
| 38 | |
| 39 | if (existsSync(filename)) { |
| 40 | rmSync(filename) |
| 41 | } |
| 42 | onTestFinished(() => { |
| 43 | if(existsSync(filename)) { |
| 44 | rmSync(filename) |
| 45 | } |
| 46 | }) |
| 47 | |
| 48 | writeFileSync(filename, ` |
| 49 | // File created by coverage/fixtures/src/dynamic-files.ts |
| 50 | module.exports.run = function run() { |
| 51 | return "Import works" |
| 52 | } |
| 53 | function uncovered() {} |
| 54 | `.trim(), 'utf-8') |
| 55 | |
| 56 | const { run } = createRequire(import.meta.url)(filename) |
| 57 | |
| 58 | if (run() !== 'Import works') { |
| 59 | throw new Error(`Failed to run ${filename}`) |
| 60 | } |
| 61 | |
| 62 | return "Done" |
| 63 | } |
no test coverage detected