gpt4 book ai didi

单元测试中的 Javascript 引用错误

转载 作者:行者123 更新时间:2023-11-28 07:57:01 24 4
gpt4 key购买 nike

我正在使用 jasmine 和 chutzpah 为我的 angularjs 解决方案编写单元测试,并且我不断收到一个 ReferenceError ,说它找不到变量模块...

这是我不断收到的错误消息:

Test Name: appControllersTest encountered a declaration exception Test FullName: ..\scripts_references.js::appcontrollerstest::encountered a declaration exception Test Source: ..\scripts_references.js : line 0 Test Outcome: Failed Test Duration: 0:00:00.001 Result Message: ReferenceError: Can't find variable: module in file:../scripts/unittest/controllerstest.js:20

Test Name: appControllersTest encountered a declaration exception Test FullName: ..\scripts\unittest\controllerstest.js::appcontrollerstest::encountered a declaration exception Test Source: ..\scripts\unittest\controllerstest.js : line 16 Test Outcome: Failed Test Duration: 0:00:00.001 Result Message: ReferenceError: Can't find variable: module in file:../scripts/unittest/controllerstest.js:20

这是我的单元测试:

/// <reference path="../_references.js" />
/// <reference path="../AngularJSApp/controllers.js" />

describe("appControllersTest", function () {
var $scope;

beforeEach(module("appMain"));

describe("RRCtrl", function () {

beforeEach(inject(function ($controller) {
$scope = {};
$controller("RRCtrl", { $scope: $scope });
}));

it("JavaTestTest", function ($controller) {
expect(scope.$root.title).toBe("");
});
});
});

有人遇到过这种错误吗?如何解决?

最佳答案

找出问题所在。 _reference.js 中某些引用的声明顺序错误。手动更改后,它起作用了。

关于单元测试中的 Javascript 引用错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25974141/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com