當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript colo.red函數代碼示例

本文整理匯總了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);
  }
開發者ID:bouzuya,項目名稱:eater-b-reporter,代碼行數:29,代碼來源:index.ts

示例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);
  }
開發者ID:bouzuya,項目名稱:beater-cli-reporter,代碼行數:14,代碼來源:index.ts

示例3:

 .forEach(([fileName, errorMessage], index) => {
   console.log(`${red('✗ failure: ')}${fileName}`);
   console.log(errorMessage);
 });
開發者ID:bouzuya,項目名稱:eater-b-reporter,代碼行數:4,代碼來源:index.ts

示例4:

 failed.forEach(({ test, error: { name, message } }) => {
   console.log(`${red(x + ' failure: ')}${test.name}`);
   console.log(`${name}: ${message}`);
 });
開發者ID:bouzuya,項目名稱:beater-cli-reporter,代碼行數:4,代碼來源:index.ts


注:本文中的colo.red函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。