Open sh977218 opened 6 months ago
In typescript, I import NYC from 'nyc', and generate report, check code coverage programmatically. new NYC().checkCoverage(coverageThresholds) should have option to throw error at end, instead of just purely console.error this is my example code:
import NYC from 'nyc'; //"nyc": "^15.1.0", try { const nycOutput = join(__dirname, '.', '.nyc_output'); const nycInstance = new NYC({ cwd: join(__dirname, '.'), reportDir: `coverage-e2e`, reporter: ['lcov', 'json', 'text-summary'], }); await nycInstance.checkCoverage(coverageThresholds); await nycInstance.report(); await fs.rm(nycOutput, { recursive: true, force: true }); } catch (e) { // NYC doesn't throw error when coverage is not met. bug console.error('Insufficient playwright code coverage!'); }
checkCoverage() only set process.exitCode = 1 when insufficient coverage met, but in my use case, process is not passed into NYC class.
cache: false
# paste the output here
Expected Behavior
In typescript, I import NYC from 'nyc', and generate report, check code coverage programmatically. new NYC().checkCoverage(coverageThresholds) should have option to throw error at end, instead of just purely console.error this is my example code:
Observed Behavior
checkCoverage() only set process.exitCode = 1 when insufficient coverage met, but in my use case, process is not passed into NYC class.
Troubleshooting steps
cache: false
in my nyc configEnvironment Information