2016-09-30 77 views
2

背景:我使用Jasmine作爲我的量角器測試框架,我一直在使用jasmine spec reporter進行報告。昨天我稍微改變了我的量角器conf.js我jasmineNodeOpts參數包括print()功能即JasmineNodeOpts - 打印量角器測試結果

jasmineNodeOpts: { 
    showColors: true, 
    defaultTimeoutInterval: 120000, 
    includeStackTrace : true, 
    isVerbose : true, 
    print: function() {} 
}, 

,因爲我學會了將各自報告之前刪除.我加入這個打印功能。例如,用我的測試報告回來:

. ✓ should display a profile question about IT loads 
. ✓ checks the width of the progress bar 
. ✓ selects an option from the radio buttons and updates the progress bar 

而現在這些領先的點都被刪除。不過,現在我的最終報告也略有改變來自:

14 specs, 2 failures Finished in 45.473 seconds // this is the old, desired output 

要這樣:

Executed 14 of 14 specs (2 FAILED) in 45 secs. // this is my current, undesired output 

我想兩全其美的,具有.從我的報告中刪除,但保留了以前的總報告。

問題:我不能jasmineNodeOpts和/或print()功能找到詳細文檔。它在jasmine-spec-reporterprotractor reference conf中被提及,但是它沒有真正的工作原理文檔,只提供了很弱的例子。

有誰知道我在哪裏可以瞭解更多關於這個print()函數和/或如何更改我的最終測試輸出?

回答

1

我對這種情況有一個解決方案。這是怎樣的一個黑客,在jasmine-spec-reporter一個小的變化 - 與下面的邏輯

summary: function (metrics) { 

    this.log(metrics.executedSpecs + ' specs, ' + metrics.failedSpecs+ ' failures Finished in ' + metrics.duration); 
    if (metrics.random) { 
     this.log('Randomized with seed ' + metrics.seed + '.'); 
    } 
    }, 

我剛纔檢查和其產生的執行摘要,你是summary(metrics)node_modules/jasmine-spec-reporter/src/spec-display.js - displaySummary邏輯

更換方法期待

Spec started 

    - sample test 
    √ Dummy Test 
    √ Dummy Test2 
    √ Dummy Test3 


3 specs, 0 failures 
Finished in 27.544 seconds 

    3 specs,0 failures Finished in 28 secs 
+0

太棒了,謝謝你。完美工作。不知道爲什麼我自己沒有想到編輯記者,我被困在如何配置'print()'函數:) – Gunderson

+0

Np ..很高興它工作! – AdityaReddy