1
我正在測試一些JavaScript與Jasmine通過Gulp。我想創建自己的記者。在這個時候,我的記者是如此的基本。它看起來像這樣:茉莉花 - 使用自定義報告人
'use strict';
var myCustomReporter = {
jasmineStarted: function(suiteInfo) {
console.log('Running suite with ' + suiteInfo.totalSpecsDefined);
console.log('Reporting via MyCustomReporter');
},
suiteStarted: function(result) {
console.log('Suite started: ' + result.description + ' whose full description is: ' + result.fullName);
},
specStarted: function(result) {
console.log('Spec started: ' + result.description + ' whose full description is: ' + result.fullName);
},
specDone: function(result) {
},
suiteDone: function(result) {
},
jasmineDone: function() {
console.log('Finished suite');
}
};
上面的代碼基本上是由茉莉提供的example custom reporter。我的挑戰是,我無法弄清楚如何讓Jasmine真正使用它。一些如何,我不正確地添加它。我加入這樣的:
gulp.task('test', function() {
// Load the reporters to use with Jasmine
var myReporter = require('./reporters/myCustomReporter');
var reporters = [
myReporter
];
return gulp.src(input.tests)
.pipe(jasmine({ reporter: reporters }))
;
});
當我通過咕嘟咕嘟執行test
任務,我得到下面的輸出:
[08:04:15] Using gulpfile ~/MyProject/gulpfile.js
[08:04:15] Starting 'test'...
[08:04:20] 'test' errored after 5.25 s
[08:04:20] Error in plugin 'gulp-jasmine'
Message:
Tests failed
如果我不同意{ reporter: reporters }
我呼籲茉莉花通過,我的測試運行得很好。我試圖學習如何a)添加我的記者和b)仍然使用默認的記者。本質上,我試圖找出如何將結果發送給多個記者。我認爲我的方法是正確的。顯然,結果顯示我錯了。
其中茉莉的版本?你讀過文檔嗎? –
@ DanielA.White我讀過文檔。這就是爲什麼我超級困惑,它不工作。在我的package.json文件中,我有''gulp-jasmine「:」^ 2.0.1「' – user70192
@ DanielA.White我的基礎語法是基於這裏顯示的:https://github.com/sindresorhus/gulp -jasmine – user70192