[英]Karma.js: Does anyone know how to make karma return filename of logging / errors
我正在使用requirejs進行一個不太復雜的項目-問題是我有一些實用程序方法可將信息記錄到控制台,這引起了我的注意,這個問題我已經有一段時間了,但是從未問過:
在不使用堆棧跟蹤的情況下 ,如何確定該ONE文件的名稱/位置?
要么
過濾/優化/定義業力輸出的最簡單方法是什么 (除了調整logLevel)?
我研究過不同的記者,並將盡快在這里為業力撰寫一篇,我只是想確保我知道有哪些可用(如果適用)。
module.exports = function (config) {
config.set ({
basePath : '../',
frameworks : ['mocha', 'requirejs', 'chai'],
files : [
{pattern: 'tests/_*.js', included: false},
'tests/test-main.js'
],
reporters : ['dots', 'growl'],
port : 9876,
logLevel : config.LOG_DEBUG,
//autoWatch : true,
autoWatch : false,
plugins : [
'karma-requirejs',
'karma-mocha',
'karma-chai',
],
singleRun : false
});
};
我看到您正在使用摩卡:我建議使用一種“測試標題”的方法,而不是一種“文件名”的方法。
像下面這樣的解決方案呢?它也可以通過自定義報告程序以業力實現:
afterEach(function(){
// use here a global variable or
// appending it as property on the runner
if(variableToLookAt){
console.log(this.currentTest.fullTitle() + ': '+your_message_here);
}
});
上面的代碼段可以插入到describe
套件塊中,或者在嵌套套件的情況下更好地插入包含測試( it
)的每個塊中。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.