Skip to content

Commit

Permalink
Merge pull request #18 from whyboris/removesettingvar
Browse files Browse the repository at this point in the history
Remove suppressErrorHighlighting user setting
  • Loading branch information
whyboris authored Aug 16, 2017
2 parents 478b279 + b5738ca commit 708a931
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 111 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ module.exports = function(config) {
removeLinesContaining: [],
removeTail: false,
renderOnRunCompleteOnly: false,
suppressErrorHighlighting: false,
suppressErrorReport: false,
underlineFileType: '',
colorBrowser: 205,
Expand All @@ -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 | <img src="http://medyk.org/colors/ffd7d7.png" style="border: 1px solid black" width="20" height="20" />
Expand Down
11 changes: 1 addition & 10 deletions lib/data/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -86,10 +85,6 @@ exports.setMaxLogLines = function(maxLogLines) {
}
};

exports.suppressErrorHighlighting = function() {
errorHighlightingEnabled = false;
};

/**
* Suite - Class
*
Expand Down Expand Up @@ -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++;
Expand Down
2 changes: 0 additions & 2 deletions lib/helpful.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ function Helpful(baseReporterDecorator, formatError, config) {
removeLinesContaining: [],
removeTail: false,
renderOnRunCompleteOnly: false,
suppressErrorHighlighting: true,
suppressErrorReport: false,
underlineFileType: null
};
Expand Down Expand Up @@ -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();

}
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
91 changes: 27 additions & 64 deletions test/data.types.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,17 @@ 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 = {
'erase': sinon.stub(),
'colorTestName': sinon.stub(),
'colorUnderline': sinon.stub(),
'white': sinon.stub(),
'red': sinon.stub(),
'white': sinon.stub(),
'yellow': sinon.stub(),
'redBright': sinon.stub(),
'blackBright': sinon.stub(),
'move': {
'right': sinon.stub()
},
Expand All @@ -38,12 +34,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();
});

Expand Down Expand Up @@ -172,15 +168,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;
});
});

});

/**
Expand Down Expand Up @@ -350,31 +337,22 @@ 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);
// ok(clcFake.black.bgRed.getCall(0).calledWithExactly(errors[2]));
});

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 + blackBright,
right + '1) ',
right,
right + bgRed,
].join('\n');

Expand All @@ -383,21 +361,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);
Expand All @@ -412,10 +375,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() {
Expand All @@ -439,9 +402,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;
});
});

Expand All @@ -457,12 +420,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;
});
});

Expand Down Expand Up @@ -503,9 +466,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'));
});
});

Expand All @@ -524,9 +487,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'));
});
});
});
Expand Down
16 changes: 1 addition & 15 deletions test/helpful.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -186,7 +184,6 @@ describe('helpful.js test suite', function() {
'underlineFileType' : 'spec.ts',
'maxLogLines' : 9001,
'renderOnRunCompleteOnly' : true,
'suppressErrorHighlighting' : true,
'suppressErrorReport' : true,
'someOtherOption' : 1234,
};
Expand All @@ -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
Expand Down
2 changes: 0 additions & 2 deletions test/printers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,11 @@ describe('printers.js test suite', function() {
beforeEach(function(done) {
clcFake = {
'red': sinon.stub(),
'redBright': sinon.stub(),
'cyan': sinon.stub(),
'green': sinon.stub(),
'move': {
'right': sinon.stub()
},
'blackBright': sinon.stub(),
'white': sinon.stub(),
'yellow': sinon.stub(),
'xterm': sinon.stub()
Expand Down
Loading

0 comments on commit 708a931

Please sign in to comment.