Skip to content

Commit

Permalink
feat: move suite pretty printing to LineWriter
Browse files Browse the repository at this point in the history
  • Loading branch information
Vadim Dalecky authored and Vadim Dalecky committed Nov 7, 2017
1 parent 105fca6 commit 2c28898
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
8 changes: 8 additions & 0 deletions src/LineWriter.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,14 @@ class LineWriter {

this.logger.error(formattedMessages);
}

suite (isFail, dir, base) {
const label = isFail ?
chalk`{bgRed.rgb(255,255,255).bold FAIL }` :
chalk`{bgGreen.rgb(255,255,255).bold PASS }`;

this.comment(chalk`${label} {grey ${this.getPathRelativeToRoot(dir)}${path.sep}}{bold ${base}}`);
}
}

module.exports = LineWriter;
11 changes: 5 additions & 6 deletions src/TapReporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,12 @@ class TapReporter {

if (testFilePath) {
const {dir, base} = path.parse(testFilePath);
const prefix = this._watch ? '' : '\n';
const label = numFailingTests > 0 ?
chalk`{bgRed.rgb(255,255,255).bold FAIL }` :
chalk`{bgGreen.rgb(255,255,255).bold PASS }`;
const tapLine = chalk`${prefix}{hidden #} ${label} {grey ${this.pathRelativeToRoot(dir)}${path.sep}}{bold ${base}}`;

this.logger.info(tapLine + '\n');
if (!this._watch) {
this.writer.blank();
}
this.writer.suite(numFailingTests > 0, dir, base);
this.writer.blank();
}

testResults.forEach(this.onAssertionResult);
Expand Down

0 comments on commit 2c28898

Please sign in to comment.