Skip to content

Commit f650d7c

Browse files
committed
test(): output failure and success color distinguished
Signed-off-by: Vojtech Masek <[email protected]>
1 parent 4ed1694 commit f650d7c

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/tests.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ import * as rimraf from 'rimraf';
44
import { promisify } from 'util';
55
import { generateAPIClient } from '../src/generator';
66

7+
const enum Colors {
8+
Reset = "\x1b[0m",
9+
Red = "\x1b[31m",
10+
Green = "\x1b[32m",
11+
}
12+
713
const testReferences = ['esquare', 'gcloud-firestore', 'github'];
814

915
const compareOptions = {compareSize: true};
@@ -35,6 +41,7 @@ async function runTests(): Promise<number> {
3541
const {same, equal, distinct, differences, left, right, diffSet} = await compare(`${refDir}/api`, genDir, compareOptions);
3642

3743
if (!same) {
44+
console.info(Colors.Red, `Test for ${reference} has failed\n`, Colors.Reset);
3845
console.group(`Stats for ${reference}`);
3946
console.info(`equal: ${equal}`);
4047
console.info(`distinct: ${distinct}`);
@@ -56,7 +63,7 @@ async function runTests(): Promise<number> {
5663

5764
return 1;
5865
} else {
59-
console.info(`Test for ${reference} has successfully passed\n\n`);
66+
console.info(Colors.Green, `Test for ${reference} has successfully passed\n\n`, Colors.Reset);
6067
await promisify(rimraf)(genDir);
6168
return 0;
6269
}
@@ -67,9 +74,9 @@ async function runTests(): Promise<number> {
6774

6875
runTests().then((failedTestsCount) => {
6976
if (failedTestsCount) {
70-
console.info(`Tests execution has ended. ${failedTestsCount} of ${testReferences.length} tests has failed\n`);
77+
console.info(Colors.Red, `Tests execution has ended. ${failedTestsCount} of ${testReferences.length} tests has failed\n`, Colors.Reset);
7178
process.exit(1);
7279
} else {
73-
console.info('Tests execution has ended successfully');
80+
console.info(Colors.Green, 'Tests execution has ended successfully', Colors.Reset);
7481
}
7582
});

0 commit comments

Comments
 (0)