(content: string)
| 44 | } |
| 45 | |
| 46 | function addLcovToJest(content: string): string { |
| 47 | try { |
| 48 | const mod = parseModule(content); |
| 49 | const config = getDefaultExportOptions(mod); |
| 50 | const reporters = config['coverageReporters']; |
| 51 | if (!reporters?.['length']) { |
| 52 | return content; |
| 53 | } |
| 54 | deepMergeObject( |
| 55 | config, |
| 56 | buildNestedObject(['coverageReporters'], [...reporters, 'lcov']), |
| 57 | ); |
| 58 | return generateCode(mod).code; |
| 59 | } catch { |
| 60 | return content; |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | export function buildNestedObject( |
| 65 | segments: string[], |
no test coverage detected