karma-brief-reporter
Advanced tools
Comparing version 0.0.8 to 0.1.0
@@ -46,3 +46,6 @@ 'use strict' | ||
if (!this.options.suppressErrorReport) { | ||
this.store.save(browser, result) | ||
const failure = this.store.save(browser, result) | ||
if (!this.options.suppressErrorReportDuringRun) { | ||
printers.printTestFailureDuringRun(failure) | ||
} | ||
} | ||
@@ -82,2 +85,3 @@ | ||
suppressErrorReport: false, | ||
suppressErrorReportDuringRun: false, | ||
suppressErrorHighlighting: false, | ||
@@ -84,0 +88,0 @@ renderOnRunCompleteOnly: false |
@@ -17,3 +17,3 @@ 'use strict' | ||
this.saveResultToSuite(suite, browser, result) | ||
return this.saveResultToSuite(suite, browser, result) | ||
} | ||
@@ -33,2 +33,4 @@ } | ||
} | ||
return { suite, test, browser: browserInfo } | ||
} | ||
@@ -35,0 +37,0 @@ |
@@ -83,2 +83,16 @@ 'use strict' | ||
function formatError (error) { | ||
error = errorFormatterMethod(error).trim() | ||
if (error.length) { | ||
if (error.indexOf('node_modules/') < 0 && errorHighlightingEnabled) { | ||
error = clc.black.bgRed(error) | ||
} else { | ||
error = clc.blackBright(error) | ||
} | ||
} | ||
return error | ||
} | ||
Browser.prototype.toString = function () { | ||
@@ -95,10 +109,4 @@ let depth = this.depth | ||
} else { | ||
error = errorFormatterMethod(error).trim() | ||
error = formatError(error) | ||
if (error.length) { | ||
if (error.indexOf('node_modules/') < 0 && errorHighlightingEnabled) { | ||
error = clc.black.bgRed(error) | ||
} else { | ||
error = clc.blackBright(error) | ||
} | ||
out.push(tabs(depth + 2) + error) | ||
@@ -112,4 +120,26 @@ } | ||
Browser.prototype.toStandaloneString = function (suite, test) { | ||
const out = [] | ||
out.push(clc.white(suite.name)) | ||
out.push(tabs(1) + clc.red(test.name)) | ||
out.push(tabs(2) + clc.yellow(this.name)) | ||
this.errors.forEach(function (error, i) { | ||
error = error.trim() | ||
if (i === 0) { | ||
out.push(tabs(3) + clc.redBright(error)) | ||
} else { | ||
error = formatError(error) | ||
if (error.length) { | ||
out.push(tabs(4) + error) | ||
} | ||
} | ||
}) | ||
return out.join('\n') | ||
} | ||
exports.Suite = Suite | ||
exports.Test = Test | ||
exports.Browser = Browser |
@@ -61,2 +61,9 @@ 'use strict' | ||
exports.printTestFailureDuringRun = function ({ suite, test, browser } = {}) { | ||
if (browser) { | ||
const message = browser.toStandaloneString(suite, test) | ||
write(clc.fixMoveRight('\n\n' + message + '\n\n')) | ||
} | ||
} | ||
exports.printTestFailures = function (failedSuites) { | ||
@@ -63,0 +70,0 @@ if (failedSuites.length) { |
{ | ||
"name": "karma-brief-reporter", | ||
"description": "Reports test progress statistics and lists failures at the end of a Karma test run.", | ||
"version": "0.0.8", | ||
"version": "0.1.0", | ||
"homepage": "https://github.com/prantlf/karma-brief-reporter", | ||
@@ -6,0 +6,0 @@ "author": { |
@@ -92,2 +92,6 @@ [![npm version](https://badge.fury.io/js/karma-brief-reporter.svg)](http://badge.fury.io/js/karma-brief-reporter) | ||
// Suppress the immediate error report after each failing test. | ||
// If this is set to true, suppressErrorReport has to be true too. | ||
suppressErrorReportDuringRun: true, // default is false | ||
// Suppress the red background on errors in the error | ||
@@ -94,0 +98,0 @@ // report at the end of the test run. |
@@ -56,2 +56,3 @@ /* eslint-env mocha */ | ||
'printRuntimeErrors': sinon.spy(), | ||
'printTestFailureDuringRun': sinon.spy(), | ||
'printTestFailures': sinon.spy(), | ||
@@ -108,2 +109,3 @@ 'printProgress': sinon.spy(), | ||
expect(brief.options.suppressErrorReport).to.be.false | ||
expect(brief.options.suppressErrorReportDuringRun).to.be.false | ||
expect(brief.options.suppressErrorHighlighting).to.be.false | ||
@@ -119,2 +121,3 @@ expect(brief.options.renderOnRunCompleteOnly).to.be.false | ||
'suppressErrorReport': true, | ||
'suppressErrorReportDuringRun': true, | ||
'suppressErrorHighlighting': true, | ||
@@ -129,2 +132,3 @@ 'renderOnRunCompleteOnly': true, | ||
expect(brief.options.suppressErrorReport).to.be.true | ||
expect(brief.options.suppressErrorReportDuringRun).to.be.true | ||
expect(brief.options.suppressErrorHighlighting).to.be.true | ||
@@ -322,2 +326,15 @@ expect(brief.options.renderOnRunCompleteOnly).to.be.true | ||
}) | ||
it('should only print the failure immediately when suppressErrorReportDuringRun is false', function () { | ||
brief.options.suppressErrorReportDuringRun = true | ||
brief.onSpecComplete(browser, result) | ||
expect(printersFake.printTestFailureDuringRun.called).to.be.false | ||
brief.options.suppressErrorReportDuringRun = false | ||
brief.onSpecComplete(browser, result) | ||
expect(printersFake.printTestFailureDuringRun.calledOnce).to.be.true | ||
expect(storeInstanceFake.save.calledWithExactly(browser, result)).to.be.true | ||
}) | ||
}) | ||
@@ -324,0 +341,0 @@ |
@@ -38,2 +38,5 @@ /* eslint-env mocha */ | ||
clcFake.black.bgRed.returns(' ') | ||
clcFake.blackBright.returns(' ') | ||
types = rewire('../lib/data/types') | ||
@@ -155,3 +158,3 @@ types.__set__('clc', clcFake) | ||
describe('Browser - class ', function () { | ||
let browser, name, depth, errors | ||
let browser, test, suite, name, depth, errors | ||
@@ -166,2 +169,5 @@ beforeEach(function () { | ||
browser.errors = errors | ||
test = new types.Test('test') | ||
suite = new types.Suite('suite') | ||
}) | ||
@@ -224,2 +230,32 @@ | ||
it('should return the expected string when toStandaloneString is called', function () { | ||
let expected, actual | ||
let white = 'white' | ||
let red = 'red' | ||
let yellow = 'yellow>' | ||
let redBright = 'redBright>' | ||
let blackBright = 'blackBright>' | ||
let bgRed = 'bgRed>' | ||
clcFake.white.returns(white) | ||
clcFake.red.returns(red) | ||
clcFake.yellow.returns(yellow) | ||
clcFake.redBright.returns(redBright) | ||
clcFake.blackBright.returns(blackBright) | ||
clcFake.black.bgRed.returns(bgRed) | ||
expected = [ | ||
white, | ||
right + red, | ||
right + yellow, | ||
right + redBright, | ||
right + blackBright, | ||
right + bgRed | ||
].join('\n') | ||
actual = browser.toStandaloneString(suite, test) | ||
eq(expected, actual) | ||
}) | ||
describe('errorHighlighting', function () { | ||
@@ -226,0 +262,0 @@ it('should not use black.bgRed when suppressErrorHighlighting is called', function () { |
57854
1497
143