Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI: Limit colors in TAP reporter to test names #1801

Merged
merged 1 commit into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/core/reporters/TapReporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ export default class TapReporter {
if (!this.ended) {
this.onRunStart();
this.testCount = this.testCount + 1;
this.log(kleur.red(`not ok ${this.testCount} global failure`));
this.log(`not ok ${this.testCount} ${kleur.red('global failure')}`);
this.logError(error);
}

Expand All @@ -227,16 +227,16 @@ export default class TapReporter {
this.log(`ok ${this.testCount} ${test.fullName.join(' > ')}`);
} else if (test.status === 'skipped') {
this.log(
kleur.yellow(`ok ${this.testCount} # SKIP ${test.fullName.join(' > ')}`)
`ok ${this.testCount} ${kleur.yellow(`# SKIP ${test.fullName.join(' > ')}`)}`
);
} else if (test.status === 'todo') {
this.log(
kleur.cyan(`not ok ${this.testCount} # TODO ${test.fullName.join(' > ')}`)
`not ok ${this.testCount} ${kleur.cyan(`# TODO ${test.fullName.join(' > ')}`)}`
);
test.errors.forEach((error) => this.logAssertion(error, 'todo'));
} else {
this.log(
kleur.red(`not ok ${this.testCount} ${test.fullName.join(' > ')}`)
`not ok ${this.testCount} ${kleur.red(test.fullName.join(' > '))}`
);
test.errors.forEach((error) => this.logAssertion(error));
}
Expand All @@ -247,9 +247,9 @@ export default class TapReporter {

this.log(`1..${runEnd.testCounts.total}`);
this.log(`# pass ${runEnd.testCounts.passed}`);
this.log(kleur.yellow(`# skip ${runEnd.testCounts.skipped}`));
this.log(kleur.cyan(`# todo ${runEnd.testCounts.todo}`));
this.log(kleur.red(`# fail ${runEnd.testCounts.failed}`));
this.log(`# ${kleur.yellow(`skip ${runEnd.testCounts.skipped}`)}`);
this.log(`# ${kleur.cyan(`todo ${runEnd.testCounts.todo}`)}`);
this.log(`# ${kleur.red(`fail ${runEnd.testCounts.failed}`)}`);
}

logAssertion (error, severity) {
Expand Down
14 changes: 7 additions & 7 deletions test/main/TapReporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ QUnit.module('TapReporter', function (hooks) {
});

QUnit.test('output ok for a skipped test', function (assert) {
var expected = kleur.yellow('ok 1 # SKIP name');
var expected = 'ok 1 ' + kleur.yellow('# SKIP name');

emitter.emit('testEnd', {
name: 'name',
Expand All @@ -100,7 +100,7 @@ QUnit.module('TapReporter', function (hooks) {
});

QUnit.test('output not ok for a todo test', function (assert) {
var expected = kleur.cyan('not ok 1 # TODO name');
var expected = 'not ok 1 ' + kleur.cyan('# TODO name');

emitter.emit('testEnd', {
name: 'name',
Expand All @@ -115,7 +115,7 @@ QUnit.module('TapReporter', function (hooks) {
});

QUnit.test('output not ok for a failing test', function (assert) {
var expected = kleur.red('not ok 1 name');
var expected = 'not ok 1 ' + kleur.red('name');

emitter.emit('testEnd', {
name: 'name',
Expand Down Expand Up @@ -143,7 +143,7 @@ QUnit.module('TapReporter', function (hooks) {
assertions: []
});

assert.strictEqual(buffer, kleur.red('not ok 1 name') + '\n'
assert.strictEqual(buffer, 'not ok 1 ' + kleur.red('name') + '\n'
+ ' ---\n'
+ ' message: first error\n'
+ ' severity: failed\n'
Expand All @@ -168,7 +168,7 @@ QUnit.module('TapReporter', function (hooks) {
emitter.clear();
emitter.emit('error', 'Boo');

assert.strictEqual(buffer, kleur.red('not ok 1 global failure') + '\n'
assert.strictEqual(buffer, 'not ok 1 ' + kleur.red('global failure') + '\n'
+ ' ---\n'
+ ' message: Boo\n'
+ ' severity: failed\n'
Expand All @@ -184,7 +184,7 @@ QUnit.module('TapReporter', function (hooks) {
emitter.clear();
emitter.emit('error', err);

assert.strictEqual(buffer, kleur.red('not ok 1 global failure') + '\n'
assert.strictEqual(buffer, 'not ok 1 ' + kleur.red('global failure') + '\n'
+ ' ---\n'
+ ' message: ReferenceError: Boo is not defined\n'
+ ' severity: failed\n'
Expand Down Expand Up @@ -437,7 +437,7 @@ QUnit.module('TapReporter', function (hooks) {
});

assert.strictEqual(buffer, '1..6\n'
+ '# pass 3\n' + kleur.yellow('# skip 1') + '\n' + kleur.cyan('# todo 0') + '\n' + kleur.red('# fail 2') + '\n'
+ '# pass 3\n# ' + kleur.yellow('skip 1') + '\n# ' + kleur.cyan('todo 0') + '\n# ' + kleur.red('fail 2') + '\n'
);
});
});
Loading