Skip to content

Commit

Permalink
Correctly fix prefix length alignment. Remove colors in error subtitl…
Browse files Browse the repository at this point in the history
…e. Bump version once again =/ (#625)
  • Loading branch information
inikulin authored and kirovboris committed Jun 28, 2016
1 parent c0d9d71 commit 331cb37
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "testcafe",
"version": "0.0.20",
"version": "0.0.21",
"main": "lib/index",
"bin": {
"testcafe": "./bin/testcafe"
Expand Down
4 changes: 2 additions & 2 deletions src/errors/test-run/templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ function markup (err, msgMarkup) {
var prefix = `<span class="user-agent">${err.userAgent}</span>\n`;

if (err.testRunState === TEST_RUN_STATE.inBeforeEach)
prefix += `<span class="subtitle">Error in <code>beforeEach</code> hook</span>`;
prefix += `<span class="subtitle">Error in beforeEach hook</span>`;

else if (err.testRunState === TEST_RUN_STATE.inAfterEach)
prefix += `<span class="subtitle">Error in <code>afterEach</code> hook</span>`;
prefix += `<span class="subtitle">Error in afterEach hook</span>`;

msgMarkup = prefix + dedent(msgMarkup);

Expand Down
11 changes: 6 additions & 5 deletions src/reporter/plugin-host.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,16 @@ export default class ReporterPluginHost {
}

formatError (err, prefix = '') {
var maxMsgLength = this[viewportWidth] - this[indent] - removeTTYColors(prefix).length;
var msg = err.formatMessage(this[errorDecorator], maxMsgLength);
var prefixLengthWithoutColors = removeTTYColors(prefix).length;
var maxMsgLength = this[viewportWidth] - this[indent] - prefixLengthWithoutColors;
var msg = err.formatMessage(this[errorDecorator], maxMsgLength);

if (this[wordWrapEnabled])
msg = this.wordWrap(msg, prefix.length, maxMsgLength);
msg = this.wordWrap(msg, prefixLengthWithoutColors, maxMsgLength);
else
msg = this.indentString(msg, prefix.length);
msg = this.indentString(msg, prefixLengthWithoutColors);

return prefix + msg.substr(prefix.length);
return prefix + msg.substr(prefixLengthWithoutColors);
}


Expand Down

0 comments on commit 331cb37

Please sign in to comment.