Socket
Socket
Sign inDemoInstall

karma-brief-reporter

Package Overview
Dependencies
155
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.2 to 0.2.0

12

lib/brief.js

@@ -19,2 +19,5 @@ 'use strict'

}
if (this.options.omitExternalStackFrames) {
types.omitExternalStackFrames()
}

@@ -43,3 +46,3 @@ this.adapters = [process.stdout.write.bind(process.stdout)]

this.onSpecComplete = function (browser, result) {
const stats = this.stats = Object.create(browser.lastResult)
const stats = this.stats = browser.lastStats = Object.create(browser.lastResult)
ensureStats.call(this)

@@ -56,3 +59,3 @@ updateStats.call(this, stats)

if (!this.options.renderOnRunCompleteOnly) {
printers.printProgress(this.stats)
printers.printProgress(this.browsers, this.stats)
}

@@ -63,5 +66,5 @@ }

ensureStats.call(this)
printers.printStats(this.stats)
printers.printStats(this.browsers, this.stats)
if (this.browserErrors.length) {
printers.printRuntimeErrors(this.browserErrors)
printers.printRuntimeErrors(this.browsers, this.browserErrors)
} else {

@@ -93,2 +96,3 @@ if (!this.options.earlyErrorReport) {

suppressErrorHighlighting: false,
omitExternalStackFrames: false,
renderOnRunCompleteOnly: false

@@ -95,0 +99,0 @@ }

@@ -11,2 +11,20 @@ 'use strict'

function clearUrlQuery (error) {
return error
.replace(/\?.+?:/, ':')
.replace(/\?.+( \(line \d+\))/, '$1')
}
function clearUrl (error) {
error = error
.replace(/ \(\w+:\/\/[^:]+:\d+\/base\/([^)]+)\)$/, ' ($1)')
.replace(/ in \w+:\/\/[^:]+:\d+\/base\/([^)]+\))$/, ' in $1')
.replace(/\w+:\/\/[^:]+:\d+\/base\/([^:]+:\d+:\d+)/, '$1')
return clearUrlQuery(error)
}
function detectExternalStackFrame (error) {
return error.indexOf('node_modules/') >= 0 || /(?:at )?<\w+>$/.test(error)
}
let errorHighlightingEnabled = true

@@ -18,4 +36,10 @@

let externalStackFrames = true
exports.omitExternalStackFrames = function () {
externalStackFrames = false
}
let errorFormatterMethod = function (error) {
return error.replace(/(\?.+?:)/, ':').trim()
return clearUrlQuery(error).trim()
}

@@ -89,6 +113,11 @@

if (error.length) {
if (error.indexOf('node_modules/') < 0 && errorHighlightingEnabled) {
error = clc.black.bgRed(error)
const internal = !detectExternalStackFrame(error)
if (internal || externalStackFrames) {
if (internal && errorHighlightingEnabled) {
error = clc.black.bgRed(error)
} else {
error = clc.blackBright(error)
}
} else {
error = clc.blackBright(error)
return ''
}

@@ -109,3 +138,7 @@ }

if (i === 0) {
out.push(tabs(depth + 1) + (++counter) + ') ' + clc.redBright(error))
out.push(tabs(depth + 1) + (++counter) +
') ' + clc.redBright(clearUrl(error)))
} else if (i === 1 && /^Actual:/.test(error)) {
out.push(tabs(depth + 1) + counter.toString().replace(/./, ' ') +
' ' + clc.redBright(error))
} else {

@@ -112,0 +145,0 @@ error = formatError(error)

'use strict'
let clc = require('./cli-color-optional')
const pad = require('pad-left')
const padLeft = require('pad-left')
const padRight = require('pad-right')
function padNumber (number) {
return pad(number.toString(), 5, ' ')
return padLeft(number.toString(), 5, ' ')
}
function printStats (meaning, total, success, failed, skipped) {
function formatBrowserName (browser) {
const name = browser.name
.replace(/^(\w+).*$/, '$1')
.replace('Headless', '')
return padRight(name, 7, ' ')
}
function printStats (browser, meaning, total, success, failed, skipped) {
if (browser) {
write(clc.blackBright(formatBrowserName(browser)))
write(' ')
}
write(clc.yellow(padNumber(total) + ' ' + meaning))

@@ -22,22 +34,43 @@ write(' ')

exports.printProgress = function (stats) {
const success = stats.success
const failed = stats.failed
const skipped = stats.skipped
const pending = stats.total - success - failed - skipped
exports.printProgress = function (browsers, stats) {
function printLine (browser, stats) {
const success = stats.success
const failed = stats.failed
const skipped = stats.skipped
const pending = stats.total - success - failed - skipped
printStats(browser, 'pending', pending, success, failed, skipped)
}
printStats('pending', pending, success, failed, skipped)
write(clc.move.up(1))
if (browsers.length > 1) {
browsers.forEach(function (browser) {
printLine(browser, browser.lastStats)
})
} else {
printLine(undefined, stats)
}
write(clc.move.up(browsers.length))
}
exports.printStats = function (stats) {
printStats('total ', stats.total, stats.success, stats.failed, stats.skipped)
exports.printStats = function (browsers, stats) {
function printLine (browser, stats) {
printStats(browser, 'total ', stats.total, stats.success, stats.failed, stats.skipped)
}
if (browsers.length > 1) {
browsers.forEach(function (browser) {
printLine(browser, browser.lastStats)
})
} else {
printLine(undefined, stats)
}
write('\n')
}
exports.printRuntimeErrors = function (browserErrors) {
exports.printRuntimeErrors = function (browsers, browserErrors) {
browserErrors.forEach(function (error) {
write(clc.red(error.browser.name))
write('\n')
write('\n')
if (browsers.length > 1) {
write(clc.red(error.browser.name))
write('\n')
write('\n')
}
write(clc.red(getErrorMessage(error.error)))

@@ -44,0 +77,0 @@ write('\n')

{
"name": "karma-brief-reporter",
"description": "Reports test progress statistics and lists failures at the end of a Karma test run.",
"version": "0.1.2",
"version": "0.2.0",
"homepage": "https://github.com/prantlf/karma-brief-reporter",

@@ -31,5 +31,4 @@ "author": {

"lint": "standard --verbose",
"check": "mocha test/*",
"check": "istanbul cover node_modules/mocha/bin/_mocha --report lcov -- test/*",
"test": "npm run lint && npm run check",
"coverage": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- test/*",
"coveralls": "cat coverage/lcov.info | node_modules/coveralls/bin/coveralls.js",

@@ -42,3 +41,4 @@ "travis-deploy-once": "travis-deploy-once",

"mkdirp": "0.5.1",
"pad-left": "2.1.0"
"pad-left": "2.1.0",
"pad-right": "0.2.2"
},

@@ -45,0 +45,0 @@ "devDependencies": {

@@ -21,2 +21,4 @@ [![npm version](https://badge.fury.io/js/karma-brief-reporter.svg)](http://badge.fury.io/js/karma-brief-reporter)

![Demo](https://raw.githubusercontent.com/prantlf/karma-brief-reporter/master/demo.gif)
Examples

@@ -40,4 +42,4 @@ --------

http://requirejs.org/docs/errors.html#scripterror
at makeError (http://localhost:9876/base/node_modules/requirejs/require.js:168:17)
at HTMLScriptElement.onScriptError (http://localhost:9876/base/node_modules/requirejs/require.js:1738:36)
at makeError (node_modules/requirejs/require.js:168:17)
at HTMLScriptElement.onScriptError (node_modules/requirejs/require.js:1738:36)
```

@@ -105,2 +107,7 @@

// Omits stack frames from external dependencies like qunit,
// jasmine or chai, which appear in stack traces of failed
// tests and which are usually irrelevant to the tested code.
omitExternalStackFrames: true, // default is false
// Suppress the browser console log at the end of the test run.

@@ -140,3 +147,3 @@ suppressBrowserLogs: true, // default is false

Copyright (c) 2018 Ferdinand Prantl
Copyright (c) 2018-2019 Ferdinand Prantl

@@ -143,0 +150,0 @@ Licensed under the MIT license.

@@ -109,3 +109,3 @@ /* eslint-env mocha */

printers.printRuntimeErrors(runtimeErrors)
printers.printRuntimeErrors(['browser1', 'browser2', 'browser3'], runtimeErrors)

@@ -182,3 +182,3 @@ for (let i = 0; i < out.length; i++) {

printers.printStats(stats)
printers.printStats(['browser'], stats)
})

@@ -185,0 +185,0 @@

@@ -50,3 +50,4 @@ /* eslint-env mocha */

'setErrorFormatterMethod': sinon.spy(),
'suppressErrorHighlighting': sinon.spy()
'suppressErrorHighlighting': sinon.spy(),
'omitExternalStackFrames': sinon.spy()
}

@@ -111,2 +112,3 @@

expect(brief.options.suppressErrorHighlighting).to.be.false
expect(brief.options.omitExternalStackFrames).to.be.false
expect(brief.options.renderOnRunCompleteOnly).to.be.false

@@ -123,2 +125,3 @@ expect(typesFake.setErrorFormatterMethod.calledOnce).to.be.true

'suppressErrorHighlighting': true,
'omitExternalStackFrames': true,
'renderOnRunCompleteOnly': true,

@@ -134,2 +137,3 @@ 'someOtherOption': 1234

expect(brief.options.suppressErrorHighlighting).to.be.true
expect(brief.options.omitExternalStackFrames).to.be.true
expect(brief.options.renderOnRunCompleteOnly).to.be.true

@@ -148,2 +152,12 @@ expect(brief.options.someOtherOption).to.be.undefined

})
it('should omitExternalStackFrames if option is set in config', function () {
configFake.briefReporter = {
'omitExternalStackFrames': true
}
brief = new Brief(baseReporterDecorator, null, configFake)
expect(typesFake.omitExternalStackFrames.calledOnce).to.be.true
})
})

@@ -359,2 +373,3 @@

brief.browserLogs = 'browserLogs'
brief.browsers = ['browser']
})

@@ -374,3 +389,3 @@

ok(printersFake.printStats.calledOnce)
ok(printersFake.printStats.calledWithExactly(brief.stats))
ok(printersFake.printStats.calledWithExactly(['browser'], brief.stats))

@@ -381,6 +396,6 @@ ok(printersFake.printBrowserLogs.calledOnce)

it('should call the expected methods when borwserErrors is not empty', function () {
brief.browserErrors.push('I\'m an error')
it('should call the expected methods when browserErrors is not empty', function () {
brief.browserErrors.push({ browser: 'browser', error: 'I\'m an error' })
brief.onRunComplete()
ok(printersFake.printRuntimeErrors.calledWithExactly(brief.browserErrors))
ok(printersFake.printRuntimeErrors.calledWithExactly(['browser'], brief.browserErrors))
})

@@ -387,0 +402,0 @@ })

@@ -259,11 +259,6 @@ /* eslint-env mocha */

it('should not use black.bgRed when suppressErrorHighlighting is called', function () {
browser.errors = [
'Error Info',
'error1',
'error2'
]
types.suppressErrorHighlighting()
browser.toString()
ok(clcFake.black.bgRed.notCalled)
ok(clcFake.blackBright.calledTwice)

@@ -273,2 +268,12 @@ })

describe('externalStackFrames', function () {
it('should not include stack frames from external dependencies when omitExternalStackFrames is called', function () {
types.omitExternalStackFrames()
browser.toString()
ok(clcFake.black.bgRed.calledOnce)
ok(clcFake.blackBright.notCalled)
})
})
describe('errorFormatMethod tests', function () {

@@ -275,0 +280,0 @@ describe('default behavior', function () {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc