问题与AngularJS茉莉花测试 - 模块未找到茉莉花、未找到、模块、测试

由网友(初夏__呐段情)分享简介:我试图用噶/茉莉花一个非常简单的测试,单元测试我的AngularJS应用程序。这似乎是工作。I'm trying a very simple test with Karma/Jasmine, to unit test my AngularJS app. This seems to work beforeEach(m...

我试图用噶/茉莉花一个非常简单的测试,单元测试我的AngularJS应用程序。这似乎是工作。

I'm trying a very simple test with Karma/Jasmine, to unit test my AngularJS app. This seems to work

beforeEach(
        module('myApp')
);

it('should blah', function () {
    expect(true).toBe(true);
});

而这并不

beforeEach(
    function () {
        module('myApp')
    }
);

it('should blah', function () {
    expect(true).toBe(true);
});

我希望能够做其他的东西beforeEach测试套件,但它没有给我任何有意义的错误能够调试它,是唯一一个我看到的是

I want to be able to do other stuff beforeEach test suite, but it's not giving me any meaningful errors to be able to debug it, the only one I see is

TypeError: 'undefined' is not an object (evaluating 'currentSpec.queue.running')

与其中函数被称为内beforeEach在第二示例构造的行。

relating to the line where the function is called within the beforeEach construct in the second example.

林希望其他人遇到这个,可以帮助?

Im hoping someone else has come across this and can assist?

谢谢斯蒂芬

推荐答案

您那是多么声明您的模块。如果你想要做更多,你可以只使用一个额外的beforeEach。

Thats just how you declare your module. If you want to do more you can just use an additional beforeEach.

例如:

var scope;
var ctrl;
var mysvcMock;

beforeEach(module('myApp'));

beforeEach(function() {
    mysvcMock = {

    };
});

beforeEach(inject(function($rootScope, $controller) {
    scope = $rootScope.$new();
    ctrl = $controller('MyController', {
        $scope: scope,
        mysvc: mysvcMock
    });
}));

//it checks

让我知道如果你需要更多这方面的清晰度和我放在一起捣鼓你。

Let me know if you need more clarity on this and I can put together a fiddle for you.

谢谢,

乔丹

阅读全文

相关推荐

最新文章