2016-08-24 20 views
0

我正在使用Karma進行測試,我想知道是否有方法在控制檯上打印測試執行時間已結束?在karma配置上添加執行完成時間

喜歡的東西:

Chrome 52.0.2743 (Mac OS X 10.11.6): Executed 126 of 126 SUCCESS (3.516 secs/3.087 secs) 
TOTAL: 126 SUCCESS 

=============================== Coverage summary =============================== 
Statements : 23.06% (1900/8238), 118 ignored 
Branches  : 16.29% (594/3646), 160 ignored 
Functions : 23.93% (589/2461), 77 ignored 
Lines  : 18.04% (1359/7532) 
================================================================================ 

Executed: 08-24-2016 11:34:59 
Finished: 08-24-2016 11:35:42 

回答

0

您應該使用因緣覆蓋和因果報應規格記者。

添加在的package.json:

"karma-coverage": "1.1.0", 
"karma-spec-reporter" : "0.0.26" 

然後在你的業障的conf:

reporters: ['spec, 'coverage'], 

配置部分:(從文檔)

spec docs

specReporter: { 
    maxLogLines: 5,   // limit number of lines logged per test 
    suppressErrorSummary: true, // do not print error summary 
    suppressFailed: false, // do not print information about failed tests 
    suppressPassed: false, // do not print information about passed tests 
    suppressSkipped: true, // do not print information about skipped tests 
    showSpecTiming: true// print the time elapsed for each spec 
    }, 
    coverageReporter: { 
    type: 'html', 
    dir: 'release/coverage/' 
    } 

你會ge打印輸出類似於您的請求,並在發佈/覆蓋目錄中提供覆蓋報告。

+0

對不起,您是否收到我的問題?我有這個輸出,除了最後兩行......這是我的要求。我如何添加這些行?我如何將自定義打印注入控制檯? – NikosKeyz

+0

我知道的唯一插件就是規格記者之一。並啓用showSpecTiming。你的問題只是說「我想要類似的東西」,所以我試圖得到它。 – PeterS