本文整理汇总了TypeScript中colo.green函数的典型用法代码示例。如果您正苦于以下问题:TypeScript green函数的具体用法?TypeScript green怎么用?TypeScript green使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了green函数的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: reportSuccess
reportSuccess(fileName: TestName) {
this.totalFileNum += 1;
this.succeedFileNum += 1;
console.log(`${green('✓ success: ')}${fileName}`);
}
示例4: testFinished
testFinished(result: TestResult): void {
if (!!result.error) return;
console.log(`${green(v + ' success: ')}${result.test.name}`);
}