Jasmine套件未在测试运行输出中正确打印
Jasmine suites not printed properly in test run output
我正在尝试使用Jasmine(使用Karma)进行JS测试。然而,当我运行测试时,输出不清楚,测试套件(=describe())没有正确打印,而是显示[object object]。
我如何让它打印给describe()的实际文本?
谢谢你的帮助!:-)
例如,此测试套件显示以下输出。
tests.specs.js
var splitService;
var splitRepositorySpy;
describe('SplitService', function () {
beforeEach(function () {
module('PayMeBack');
splitRepositorySpy = {
list: jasmine.createSpy(),
get: jasmine.createSpy(),
insert: jasmine.createSpy()
};
module(function ($provide) {
$provide.value('splitRepository', splitRepositorySpy);
});
module(function ($provide) {
$provide.value('dateTimeProvider', { now: function () { return new Date('29 Dec 2015 15:40:55'); } });
});
inject(function ($injector) {
splitService = $injector.get('splitService');
});
});
describe('list', function () {
it('should call the repository', function () {
var splits = splitService.list();
expect(splitRepositorySpy.list).toHaveBeenCalled();
});
});
describe('get', function () {
it('should call the repository', function () {
var splits = splitService.get();
expect(splitRepositorySpy.get).toHaveBeenCalled();
});
});
describe('create', function () {
var expectedSplitName = 'Tue Dec 29 2015 15:40';
it('should call the repository with name ' + expectedSplitName, function () {
var splits = splitService.create();
expect(splitRepositorySpy.insert).toHaveBeenCalledWith(expectedSplitName);
});
});
});
Powershell控制台
PS E:'Development'Project1> karma start
INFO [karma]: Karma v0.12.0 server started at http://localhost:9876/
INFO [launcher]: Starting browser Chrome
INFO [Chrome 47.0.2526 (Windows 8.1)]: Connected on socket zBarh9jOriLwkoeai8ao with id 21844249
[object Object]
[object Object]
V should call the repository
[object Object]
[object Object]
[object Object]
V should call the repository
[object Object]
[object Object]
[object Object]
[object Object]
V should call the repository with name Tue Dec 29 2015 15:40
Chrome 47.0.2526 (Windows 8.1): Executed 3 of 3 SUCCESS (0.056 secs / 0.051 secs)
TOTAL: 3 SUCCESS
升级到"karma jasmine":"0.3.6"似乎解决了这个问题。
相关文章:
- 用Koa打印漂亮的HTML输出
- 如何使用 JQuQuery 解析 JSON 对象并在 HTML 页面中以表格格式打印输出
- ajax方法返回错误时如何打印输出
- 两个javascript网络工作者连续打印输出-为什么不同时打印呢
- 在Handlebars.js中的新行上打印输出
- 使用javascript在HTML的输出窗口中打印控制台消息
- 在 nodejs 中有什么方法可以打印 JSON 格式的 log4js 输出
- 如何使用嵌套循环使用 Javascript 打印到外部循环的输出中
- 从 utf-8 代码打印/输出 utf-8 字符
- 在 Javascript 中打印多个 html 文件的输出
- 如何将一页的输出打印到另一页(跨域)
- 打印 Javascript 而不是 ASP(经典)输出
- 如果功能多次激活,请多次停止输出打印
- 模态打印输出的变化
- JavaScript window.print()提供空白打印输出
- Javascript打印输出
- 使用javascript将图片添加到html打印输出
- PHP 实时执行永无止境的二进制/脚本打印输出
- JQuery 字符串打印输出消失
- 限制Java Script打印输出字符