From d7305fe1f93775d56929d6b56b3f5b140d7db460 Mon Sep 17 00:00:00 2001 From: whyboris Date: Wed, 16 Aug 2017 00:11:02 -0400 Subject: [PATCH 1/4] remove suppressErrorHighlighting user setting --- README.md | 2 -- lib/data/types.js | 11 +----- lib/helpful.js | 2 -- test/data.types.test.js | 80 ++++++++++++++--------------------------- test/helpful.test.js | 16 +-------- 5 files changed, 29 insertions(+), 82 deletions(-) diff --git a/README.md b/README.md index 4f84a58..1615149 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,6 @@ module.exports = function(config) { removeLinesContaining: [], removeTail: false, renderOnRunCompleteOnly: false, - suppressErrorHighlighting: false, suppressErrorReport: false, underlineFileType: '', colorBrowser: 205, @@ -72,7 +71,6 @@ maxLogLines | 42 | Limit the maximum number of lines in report removeLinesContaining | [] | Remove all lines from the final report containing any of these strings, e.g. _['@angular', 'zone.js']_ removeTail | false | Remove from the final report anything that follows '<-', e.g. _blah blah <- test.ts 4250:39_ becomes _blah blah_ renderOnRunCompleteOnly | false | Do not animate while tests are running -suppressErrorHighlighting | false | Highlight in red all lines not containing _node_modules_ suppressErrorReport | false | Suppress the error report at the end of the test run underlineFileType | '' | Underline filename of some file type; all files in the error report that have this particular extention will be underlined, e.g. _'spec.ts'_; set the color with the _colorUnderline_ property colorBrowser | 224 | diff --git a/lib/data/types.js b/lib/data/types.js index 6b331cd..b6d7802 100644 --- a/lib/data/types.js +++ b/lib/data/types.js @@ -12,7 +12,6 @@ var clc = require('cli-color'); // Global properties alphabetized var clearScreenBeforeEveryRun = false; var counter = 0; -var errorHighlightingEnabled = true; var fileExtension; var maxLines = 9999; var removeTail = false; @@ -86,10 +85,6 @@ exports.setMaxLogLines = function(maxLogLines) { } }; -exports.suppressErrorHighlighting = function() { - errorHighlightingEnabled = false; -}; - /** * Suite - Class * @@ -218,11 +213,7 @@ Browser.prototype.toString = function() { if (linesPrinted === 0) { out.push(tabs(depth + 1) + (++counter) + ') ' + colorFirstLine(error)); } else { - if (error.indexOf('node_modules/') < 0 && errorHighlightingEnabled) { - error = clc.black.bgRed(error); - } else { - error = colorLoggedErrors(error); - } + error = colorLoggedErrors(error); out.push(tabs(depth + 2) + error); } linesPrinted++; diff --git a/lib/helpful.js b/lib/helpful.js index 3d01ad1..6390c0d 100644 --- a/lib/helpful.js +++ b/lib/helpful.js @@ -33,7 +33,6 @@ function Helpful(baseReporterDecorator, formatError, config) { removeLinesContaining: [], removeTail: false, renderOnRunCompleteOnly: false, - suppressErrorHighlighting: true, suppressErrorReport: false, underlineFileType: null }; @@ -82,7 +81,6 @@ function Helpful(baseReporterDecorator, formatError, config) { self.options.maxLogLines ? dataTypes.setMaxLogLines(self.options.maxLogLines) : doNothing(); self.options.removeLinesContaining ? dataTypes.setLinesToExclude(self.options.removeLinesContaining) : doNothing(); self.options.removeTail ? dataTypes.removeTail() : doNothing(); - self.options.suppressErrorHighlighting ? dataTypes.suppressErrorHighlighting() : doNothing(); self.options.underlineFileType ? dataTypes.setFileTypeToUnderline(self.options.underlineFileType): doNothing(); } diff --git a/test/data.types.test.js b/test/data.types.test.js index 8021451..5520d14 100644 --- a/test/data.types.test.js +++ b/test/data.types.test.js @@ -13,21 +13,19 @@ var eq = assert.equal; var ok = assert.ok; describe('data/types.js test suite', function() { - var dt, clcFake, right; + var dt, clcFake, right, logSpy; var tab = 3; beforeEach(function(done) { right = 'right>'; clcFake = { + 'blackBright': sinon.stub(), 'erase': sinon.stub(), - 'colorTestName': sinon.stub(), - 'colorUnderline': sinon.stub(), - 'white': sinon.stub(), 'red': sinon.stub(), - 'yellow': sinon.stub(), 'redBright': sinon.stub(), - 'blackBright': sinon.stub(), + 'white': sinon.stub(), + 'yellow': sinon.stub(), 'move': { 'right': sinon.stub() }, @@ -38,12 +36,12 @@ describe('data/types.js test suite', function() { clcFake.move.right.returns(right); - clcFake.colorTestName.returns(clcFake.colorTestName); - - clcFake.colorUnderline.returns(clcFake.colorUnderline); - dt = rewire('../lib/data/types'); dt.__set__('clc', clcFake); + + logSpy = sinon.stub(); + dt.__set__('colorLoggedErrors', logSpy); + done(); }); @@ -172,15 +170,6 @@ describe('data/types.js test suite', function() { expect(dt.__get__("maxLines")).to.eq(9); }); }); - - describe('suppressErrorHighlighting()', function() { - it('should set errorHighlightingEnable to false', function() { - dt.__set__("errorHighlightingEnabled", true); - dt.suppressErrorHighlighting(); - expect(dt.__get__("errorHighlightingEnabled")).to.be.false; - }); - }); - }); /** @@ -383,21 +372,6 @@ describe('data/types.js test suite', function() { // eq(expected, actual); }); - describe('errorHighlighting', function() { - it('should not use black.bgRed when suppressErrorHighlighting is called', function() { - sut.errors = [ - 'Error Info', - 'error1', - 'error2' - ]; - - dt.suppressErrorHighlighting(); - sut.toString(); - - //ok(clcFake.blackBright.calledTwice); - }); - }); - describe('setMaxLogLines', function() { it('should set limit to lines when setMaxLogLines is called', function() { dt.setMaxLogLines(3); @@ -412,10 +386,10 @@ describe('data/types.js test suite', function() { sut.toString(); - ok(clcFake.black.bgRed.calledTwice); - ok(clcFake.black.bgRed.getCall(0).calledWithExactly('line 1')); - ok(clcFake.black.bgRed.getCall(1).calledWithExactly('line 2')); - expect(clcFake.black.bgRed.getCall(2)).to.be.null; + ok(logSpy.calledTwice); + ok(logSpy.getCall(0).calledWithExactly('line 1')); + ok(logSpy.getCall(1).calledWithExactly('line 2')); + expect(logSpy.getCall(2)).to.be.null; }); it('should not error out when there are no errors', function() { @@ -439,9 +413,9 @@ describe('data/types.js test suite', function() { ]; sut.toString(); - ok(clcFake.black.bgRed.calledOnce); - ok(clcFake.black.bgRed.getCall(0).calledWithExactly('some string')); - expect(clcFake.black.bgRed.getCall(1)).to.be.null; + ok(logSpy.calledOnce); + ok(logSpy.getCall(0).calledWithExactly('some string')); + expect(logSpy.getCall(1)).to.be.null; }); }); @@ -457,12 +431,12 @@ describe('data/types.js test suite', function() { 'def <-ppkf:slfkjdlfksj', ]; sut.toString(); - ok(clcFake.black.bgRed.getCall(0).calledWithExactly('some stuff')); - ok(clcFake.black.bgRed.getCall(1).calledWithExactly('hello world ')); - ok(clcFake.black.bgRed.getCall(2).calledWithExactly('abc ')); - ok(clcFake.black.bgRed.getCall(3).calledWithExactly('123')); - ok(clcFake.black.bgRed.getCall(4).calledWithExactly('def ')); - expect(clcFake.black.bgRed.getCall(5)).to.be.null; + ok(logSpy.getCall(0).calledWithExactly('some stuff')); + ok(logSpy.getCall(1).calledWithExactly('hello world ')); + ok(logSpy.getCall(2).calledWithExactly('abc ')); + ok(logSpy.getCall(3).calledWithExactly('123')); + ok(logSpy.getCall(4).calledWithExactly('def ')); + expect(logSpy.getCall(5)).to.be.null; }); }); @@ -503,9 +477,9 @@ describe('data/types.js test suite', function() { sut.toString(); - ok(clcFake.black.bgRed.calledTwice); - ok(clcFake.black.bgRed.getCall(0).calledWithExactly('some/file.js:123')); - ok(clcFake.black.bgRed.getCall(1).calledWithExactly('another/file.js:345:23')); + ok(logSpy.calledTwice); + ok(logSpy.getCall(0).calledWithExactly('some/file.js:123')); + ok(logSpy.getCall(1).calledWithExactly('another/file.js:345:23')); }); }); @@ -524,9 +498,9 @@ describe('data/types.js test suite', function() { dt.setErrorFormatterMethod(alternateFormatMethod); sut.toString(); - ok(clcFake.black.bgRed.calledTwice); - ok(clcFake.black.bgRed.getCall(0).calledWithExactly('Bob Dole error1')); - ok(clcFake.black.bgRed.getCall(1).calledWithExactly('Bob Dole error2')); + ok(logSpy.calledTwice); + ok(logSpy.getCall(0).calledWithExactly('Bob Dole error1')); + ok(logSpy.getCall(1).calledWithExactly('Bob Dole error2')); }); }); }); diff --git a/test/helpful.test.js b/test/helpful.test.js index 613bd4e..5109f96 100644 --- a/test/helpful.test.js +++ b/test/helpful.test.js @@ -68,8 +68,7 @@ describe('helpful.js test suite', function() { 'setErrorFormatterMethod' : sinon.spy(), 'setFileTypeToUnderline' : sinon.spy(), 'setLinesToExclude' : sinon.spy(), - 'setMaxLogLines' : sinon.spy(), - 'suppressErrorHighlighting' : sinon.spy() + 'setMaxLogLines' : sinon.spy() }; printersFake = { @@ -155,7 +154,6 @@ describe('helpful.js test suite', function() { expect(sut.options.removeTail).to.be.false; expect(sut.options.renderOnRunCompleteOnly).to.be.false; - expect(sut.options.suppressErrorHighlighting).to.be.true; expect(sut.options.suppressErrorReport).to.be.false; expect(sut.options.underlineFileType).to.be.null; @@ -186,7 +184,6 @@ describe('helpful.js test suite', function() { 'underlineFileType' : 'spec.ts', 'maxLogLines' : 9001, 'renderOnRunCompleteOnly' : true, - 'suppressErrorHighlighting' : true, 'suppressErrorReport' : true, 'someOtherOption' : 1234, }; @@ -207,21 +204,10 @@ describe('helpful.js test suite', function() { expect(sut.options.underlineFileType).to.eq('spec.ts'); expect(sut.options.maxLogLines).to.eq(9001); expect(sut.options.renderOnRunCompleteOnly).to.be.true; - expect(sut.options.suppressErrorHighlighting).to.be.true; expect(sut.options.suppressErrorReport).to.be.true; expect(sut.options.someOtherOption).to.be.undefined; }); - it('should suppressErrorHighlighting if option is set in config', function() { - configFake.helpfulReporter = { - 'suppressErrorHighlighting' : true - }; - - sut = new module.Helpful(null, null, configFake); - - expect(dataTypesFake.suppressErrorHighlighting.calledOnce).to.be.true; - }); - it('should set limit to the number of lines of error shown if option is set in config', function() { configFake.helpfulReporter = { 'maxLogLines' : 15 From db38d59a376064bceba87e15a603039e2664da5f Mon Sep 17 00:00:00 2001 From: whyboris Date: Wed, 16 Aug 2017 00:21:52 -0400 Subject: [PATCH 2/4] remove brightRed --- test/data.types.test.js | 8 +------- test/printers.test.js | 1 - 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/test/data.types.test.js b/test/data.types.test.js index 5520d14..44fb4c5 100644 --- a/test/data.types.test.js +++ b/test/data.types.test.js @@ -23,7 +23,6 @@ describe('data/types.js test suite', function() { 'blackBright': sinon.stub(), 'erase': sinon.stub(), 'red': sinon.stub(), - 'redBright': sinon.stub(), 'white': sinon.stub(), 'yellow': sinon.stub(), 'move': { @@ -339,9 +338,6 @@ describe('data/types.js test suite', function() { // ok(clcFake.yellow.calledOnce); // ok(clcFake.yellow.calledWithExactly(name)); - // ok(clcFake.redBright.calledOnce); - // ok(clcFake.redBright.calledWithExactly(errors[0])); - // ok(clcFake.blackBright.calledOnce); // ok(clcFake.blackBright.getCall(0).calledWithExactly(errors[1])); // ok(clcFake.black.bgRed.calledOnce); @@ -351,18 +347,16 @@ describe('data/types.js test suite', function() { it('should return the expected string when toString is called', function() { var expected, actual; var yellow = 'yellow>'; - var redBright = 'redBright>'; var blackBright = 'blackBright>'; var bgRed = 'bgRed>'; clcFake.yellow.returns(yellow); - clcFake.redBright.returns(redBright); clcFake.blackBright.returns(blackBright); clcFake.black.bgRed.returns(bgRed); expected = [ right + yellow, - right + '1) ' + redBright, + right + '1) ', right + blackBright, right + bgRed, ].join('\n'); diff --git a/test/printers.test.js b/test/printers.test.js index bd80206..90be8dd 100644 --- a/test/printers.test.js +++ b/test/printers.test.js @@ -24,7 +24,6 @@ describe('printers.js test suite', function() { beforeEach(function(done) { clcFake = { 'red': sinon.stub(), - 'redBright': sinon.stub(), 'cyan': sinon.stub(), 'green': sinon.stub(), 'move': { From cd340e4d07d494aca44f6cd09f53a2a6168c3f75 Mon Sep 17 00:00:00 2001 From: whyboris Date: Wed, 16 Aug 2017 00:23:02 -0400 Subject: [PATCH 3/4] remove blackBright --- test/data.types.test.js | 7 +------ test/printers.test.js | 1 - 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/test/data.types.test.js b/test/data.types.test.js index 44fb4c5..ff24bbb 100644 --- a/test/data.types.test.js +++ b/test/data.types.test.js @@ -20,7 +20,6 @@ describe('data/types.js test suite', function() { right = 'right>'; clcFake = { - 'blackBright': sinon.stub(), 'erase': sinon.stub(), 'red': sinon.stub(), 'white': sinon.stub(), @@ -338,8 +337,6 @@ describe('data/types.js test suite', function() { // ok(clcFake.yellow.calledOnce); // ok(clcFake.yellow.calledWithExactly(name)); - // ok(clcFake.blackBright.calledOnce); - // ok(clcFake.blackBright.getCall(0).calledWithExactly(errors[1])); // ok(clcFake.black.bgRed.calledOnce); // ok(clcFake.black.bgRed.getCall(0).calledWithExactly(errors[2])); }); @@ -347,17 +344,15 @@ describe('data/types.js test suite', function() { it('should return the expected string when toString is called', function() { var expected, actual; var yellow = 'yellow>'; - var blackBright = 'blackBright>'; var bgRed = 'bgRed>'; clcFake.yellow.returns(yellow); - clcFake.blackBright.returns(blackBright); clcFake.black.bgRed.returns(bgRed); expected = [ right + yellow, right + '1) ', - right + blackBright, + right, right + bgRed, ].join('\n'); diff --git a/test/printers.test.js b/test/printers.test.js index 90be8dd..59791bb 100644 --- a/test/printers.test.js +++ b/test/printers.test.js @@ -29,7 +29,6 @@ describe('printers.js test suite', function() { 'move': { 'right': sinon.stub() }, - 'blackBright': sinon.stub(), 'white': sinon.stub(), 'yellow': sinon.stub(), 'xterm': sinon.stub() From b5738ca3b32c9c5173fb71853408be89753746ec Mon Sep 17 00:00:00 2001 From: whyboris Date: Wed, 16 Aug 2017 00:26:44 -0400 Subject: [PATCH 4/4] update versions --- package.json | 8 ++++---- yarn.lock | 42 ++++++++++++++++++++++++++++++------------ 2 files changed, 34 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index 4640c82..d80fb76 100644 --- a/package.json +++ b/package.json @@ -4,18 +4,18 @@ "url": "https://github.com/whyboris/karma-helpful-reporter/issues" }, "dependencies": { - "cli-color": "^1.2.0" + "cli-color": "1.2.0" }, "description": "Karma reporter with helpful style logging.", "devDependencies": { - "chai": "4.1.0", + "chai": "4.1.1", "coveralls": "2.13.1", "istanbul": "0.4.5", "mocha": "3.5.0", "mocha-lcov-reporter": "1.3.0", "rewire": "2.5.2", - "sinon": "2.4.1", - "sinon-chai": "2.12.0" + "sinon": "3.2.0", + "sinon-chai": "2.13.0" }, "keywords": [ "karma-plugin", diff --git a/yarn.lock b/yarn.lock index fc75816..02979a6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -110,9 +110,9 @@ center-align@^0.1.1: align-text "^0.1.3" lazy-cache "^1.0.3" -chai@4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/chai/-/chai-4.1.0.tgz#331a0391b55c3af8740ae9c3b7458bc1c3805e6d" +chai@4.1.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/chai/-/chai-4.1.1.tgz#66e21279e6f3c6415ff8231878227900e2171b39" dependencies: assertion-error "^1.0.1" check-error "^1.0.1" @@ -135,7 +135,7 @@ check-error@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/check-error/-/check-error-1.0.2.tgz#574d312edd88bb5dd8912e9286dd6c0aed4aac82" -cli-color@^1.2.0: +cli-color@1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/cli-color/-/cli-color-1.2.0.tgz#3a5ae74fd76b6267af666e69e2afbbd01def34d1" dependencies: @@ -333,7 +333,7 @@ form-data@~2.1.1: combined-stream "^1.0.5" mime-types "^2.1.12" -formatio@1.2.0: +formatio@1.2.0, formatio@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/formatio/-/formatio-1.2.0.tgz#f3b2167d9068c4698a8d51f4f760a39a54d818eb" dependencies: @@ -552,6 +552,10 @@ jsprim@^1.2.2: json-schema "0.2.3" verror "1.3.6" +just-extend@^1.1.22: + version "1.1.22" + resolved "https://registry.yarnpkg.com/just-extend/-/just-extend-1.1.22.tgz#3330af756cab6a542700c64b2e4e4aa062d52fff" + kind-of@^3.0.2: version "3.2.2" resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-3.2.2.tgz#31ea21a734bab9bbb0f32466d893aea51e4a3c64" @@ -628,6 +632,10 @@ lolex@^1.6.0: version "1.6.0" resolved "https://registry.yarnpkg.com/lolex/-/lolex-1.6.0.tgz#3a9a0283452a47d7439e72731b9e07d7386e49f6" +lolex@^2.1.2: + version "2.1.2" + resolved "https://registry.yarnpkg.com/lolex/-/lolex-2.1.2.tgz#2694b953c9ea4d013e5b8bfba891c991025b2629" + longest@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/longest/-/longest-1.0.1.tgz#30a0b2da38f73770e8294a0d22e6625ed77d0097" @@ -717,6 +725,15 @@ next-tick@1: version "1.0.0" resolved "https://registry.yarnpkg.com/next-tick/-/next-tick-1.0.0.tgz#ca86d1fe8828169b0120208e3dc8424b9db8342c" +nise@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/nise/-/nise-1.0.1.tgz#0da92b10a854e97c0f496f6c2845a301280b3eef" + dependencies: + formatio "^1.2.0" + just-extend "^1.1.22" + lolex "^1.6.0" + path-to-regexp "^1.7.0" + nopt@3.x: version "3.0.6" resolved "https://registry.yarnpkg.com/nopt/-/nopt-3.0.6.tgz#c6465dbf08abcd4db359317f79ac68a646b28ff9" @@ -834,18 +851,19 @@ samsam@1.x, samsam@^1.1.3: version "1.2.1" resolved "https://registry.yarnpkg.com/samsam/-/samsam-1.2.1.tgz#edd39093a3184370cb859243b2bdf255e7d8ea67" -sinon-chai@2.12.0: - version "2.12.0" - resolved "https://registry.yarnpkg.com/sinon-chai/-/sinon-chai-2.12.0.tgz#da71e9642ef7b893ba3cf2af806396a00aa45927" +sinon-chai@2.13.0: + version "2.13.0" + resolved "https://registry.yarnpkg.com/sinon-chai/-/sinon-chai-2.13.0.tgz#b9a42e801c20234bfc2f43b29e6f4f61b60990c4" -sinon@2.4.1: - version "2.4.1" - resolved "https://registry.yarnpkg.com/sinon/-/sinon-2.4.1.tgz#021fd64b54cb77d9d2fb0d43cdedfae7629c3a36" +sinon@3.2.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/sinon/-/sinon-3.2.0.tgz#8848a66ab6e8b80b5532e3824f59f83ea2628c77" dependencies: diff "^3.1.0" formatio "1.2.0" - lolex "^1.6.0" + lolex "^2.1.2" native-promise-only "^0.8.1" + nise "^1.0.1" path-to-regexp "^1.7.0" samsam "^1.1.3" text-encoding "0.6.4"