问题与AngularJS茉莉花测试 - 模块未找到 [英] Issue with Jasmine testing on AngularJS - module not found

查看:129
本文介绍了问题与AngularJS茉莉花测试 - 模块未找到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用噶/茉莉花一个非常简单的测试,单元测试我的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.

谢谢,

乔丹

这篇关于问题与AngularJS茉莉花测试 - 模块未找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆