简体   繁体   English

茉莉花套件无法在测试运行输出中正确打印

[英]Jasmine suites not printed properly in test run output

I'm trying to make JS tests with Jasmine (using Karma). 我正在尝试使用Jasmine(使用Karma)进行JS测试。 However when I run the tests, the output is not clear, the test suites (= describe() ) are not printed properly but instead show [object Object]. 但是,当我运行测试时,输出不清楚,测试套件(= describe())不能正确打印,而是显示[object Object]。

How can I make it print the actual text given to describe()? 如何使它打印给describe()的实际文本?

Thanks for any help! 谢谢你的帮助! :-) :-)

For example this test suite shows the following output. 例如,此测试套件显示以下输出。

tests.specs.js 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 Console 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

升级到“业力茉莉花”:“ 0.3.6”似乎已经解决了这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM