Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update major libs dep fix #398 #403

Merged
merged 1 commit into from
Mar 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/in-memory-report.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
class InMemoryReport {
const { ReportBase } = require('istanbul-lib-report')

class InMemoryReport extends ReportBase {
constructor (opt) {
super(opt)
this.opt = opt
}

Expand Down
16 changes: 8 additions & 8 deletions lib/reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,11 @@ var CoverageReporter = function (rootConfig, helper, logger, emitter) {
coverageMap.merge(result.coverage)
}

this.onRunComplete = function (browsers, results) {
this.onRunComplete = async function (browsers, results) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having this function async causes result.exitCode to be set too late to be taken into account when karma exits the process.
So when the coverage check thresholds are not met, the process still exits with code 0.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've created #418 to track this issue

const checkedCoverage = {}

for (const reporterConfig of reporters) {
browsers.forEach(function (browser) {
await Promise.all(browsers.map(async (browser) => {
const coverageMap = coverageMaps[browser.id]
if (!coverageMap) {
return
Expand All @@ -231,14 +231,15 @@ var CoverageReporter = function (rootConfig, helper, logger, emitter) {
const mainDir = reporterConfig.dir || config.dir
const subDir = reporterConfig.subdir || config.subdir
const outputPath = generateOutputPath(basePath, browser.name, mainDir, subDir)
const remappedCoverageMap = await sourceMapStore.transformCoverage(coverageMap)

const options = helper.merge(config, reporterConfig, {
dir: outputPath,
subdir: '',
browser: browser,
emitter: emitter
emitter: emitter,
coverageMap: remappedCoverageMap
})
const remappedCoverageMap = sourceMapStore.transformCoverage(coverageMap).map

// If config.check is defined, check coverage levels for each browser
if (hasOwnProperty.call(config, 'check') && !checkedCoverage[browser.id]) {
Expand All @@ -250,22 +251,21 @@ var CoverageReporter = function (rootConfig, helper, logger, emitter) {
}

const context = istanbulLibReport.createContext(options)
const tree = istanbulLibReport.summarizers.pkg(remappedCoverageMap)
const report = reports.create(reporterConfig.type || 'html', options)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I can't figure out what this commit is achieving. I think it is:

fix(reporter): update calls to  match new API in istanbul-lib-report v?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I split refactoring and upgrade on separate PRs


// // If reporting to console or in-memory skip directory creation
const toDisk = !reporterConfig.type || !reporterConfig.type.match(/^(text|text-summary|in-memory)$/)

if (!toDisk && reporterConfig.file === undefined) {
tree.visit(report, context)
report.execute(context)
return
}

helper.mkdirIfNotExists(outputPath, function () {
log.debug('Writing coverage to %s', outputPath)
tree.visit(report, context)
report.execute(context)
})
})
}))
}
}

Expand Down