我有自定义记者的 Jasmine
var myReporter = {
jasmineStarted: function(suiteInfo) {
console.log('Running suite with ' + suiteInfo.totalSpecsDefined);
},
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) {
console.log('Spec: ' + result.description + ' was ' + result.status);
for(var i = 0; i < result.failedExpectations.length; i++) {
console.log('Failure: ' + result.failedExpectations[i].message);
console.log(result.failedExpectations[i].stack);
}
},
suiteDone: function(result) {
console.log('Suite: ' + result.description + ' was ' + result.status);
for(var i = 0; i < result.failedExpectations.length; i++) {
console.log('AfterAll ' + result.failedExpectations[i].message);
console.log(result.failedExpectations[i].stack);
}
},
jasmineDone: function() {
console.log('Finished suite');
}
};
jasmine.getEnv().addReporter(myReporter);
describe('Top Level suite', function() {
it('spec', function() {
expect(1).toBe(1);
});
describe('Nested suite', function() {
it('nested spec', function() {
expect(true).toBe(true);
});
});
});
直播:http://jsfiddle.net/wLnmbh88/
现在结果显示在 html 和控制台上,但我需要在 html 中关闭它。如何仅在控制台中显示测试结果?
代码示例来自 jasmine 文档。
最佳答案
无需删除 jasmine-html.js
并摆弄自定义 boot.js
。在添加您选择的记者之前,只需删除任何记者:
var jasmineReporters = require('jasmine-reporters');
jasmine.getEnv().clearReporters();
jasmine.getEnv().addReporter(new jasmineReporters.TapReporter());
关于javascript - Jasmine,关闭默认记者,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/31246293/