本文整理匯總了TypeScript中colo.red函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript red函數的具體用法?TypeScript red怎麽用?TypeScript red使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了red函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: reportFinish
reportFinish(
hasError: boolean,
errors: { [fileName: string]: ErrorMessage; }
): void {
Object
.keys(errors)
.map(fileName => [fileName, errors[fileName]])
.forEach(([fileName, errorMessage], index) => {
console.log(`${red('✗ failure: ')}${fileName}`);
console.log(errorMessage);
});
// assert this.totalFileNum === [totalFileNum in reportFileNumber];
const totalFileNum = this.totalFileNum;
// assert this.failedFileNum === Object.keys(errors).length;
const failedFileNum = this.failedFileNum;
// assert this.succeedFileNum === totalFileNum - failedFileNum;
// const succeedFileNum = this.succeedFileNum; // unused
const totalTestNum = this.totalTestNum;
const failedTestNum = this.failedTestNum;
// const succeedTestNum = this.succeedTestNum; // unused
const summary = hasError
? red(
`✗ ${failedFileNum} of ${totalFileNum} files` +
`, ${failedTestNum} of ${totalTestNum} tests failed`
)
: green(`✓ ${totalFileNum} files ${totalTestNum} tests completed`);
console.log(summary);
}
示例2: finished
finished(results: TestResult[]): void {
const passed = results.filter(({ error }) => !!!error);
const failed = results.filter(({ error }) => !!error);
failed.forEach(({ test, error: { name, message } }) => {
console.log(`${red(x + ' failure: ')}${test.name}`);
console.log(`${name}: ${message}`);
});
const summary = failed.length > 0
? red(x + ` ${failed.length} of ${results.length} tests failed`)
: green(v + ` ${results.length} tests passed`);
console.log(summary);
}
示例3:
.forEach(([fileName, errorMessage], index) => {
console.log(`${red('✗ failure: ')}${fileName}`);
console.log(errorMessage);
});
示例4:
failed.forEach(({ test, error: { name, message } }) => {
console.log(`${red(x + ' failure: ')}${test.name}`);
console.log(`${name}: ${message}`);
});