我正在使用Jasmine测试JavaScript项目。一切顺利,但突然间没有任何作品了,虽然我记不起改变了什么。我收到这个错误:
Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
这段代码中出现错误:
describe("DesktopRouter", function(){
var router;
beforeAll(function(done){
alert("1");
require(['jquery', 'backbone', '../../../public/js/app/routers/DesktopRouter'],
function($, Backbone, DesktopRouter) {
alert("2");
router = DesktopRouter;
done();
}
);
});
...
我可以看到警告显示“1”但不是第二个显示“2”的警报。相反,没有任何事情发生几秒钟,然后所有规格都返回“失败”,因为路由器是未定义的。我已经尝试在Chrome,Firefox,Opera中运行它。我有一个早期版本的项目,曾经工作过。我再次将此版本添加到我的项目中,但它也不再起作用。那可能有什么问题?
这是我的HTML代码。也许我在这里做错了,因为requirejs是异步运行的。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Jasmine Spec Runner v2.2.0</title>
<link rel="shortcut icon" type="image/png" href="lib/jasmine-2.2.0/jasmine_favicon.png">
<link rel="stylesheet" href="lib/jasmine-2.2.0/jasmine.css">
<script src="lib/jasmine-2.2.0/jasmine.js"></script>
<script src="lib/jasmine-2.2.0/jasmine-html.js"></script>
<script src="lib/jasmine-2.2.0/boot.js"></script>
<!-- auxillary variable -->
<script>
TEST = false;
</script>
<!-- libs -->
<script src="../../node_modules/requirejs/require.js"></script>
<script src="../../public/js/app/config/config.js"></script>
<!-- add spec files here -->
<script src="spec/ToastSpec.js"></script>
<script src="spec/DesktopRouterSpec.js"></script>
<script src="spec/AddVehicleViewSpec.js"></script>
<script src="spec/BaseCollectionSpec.js"></script>
</head>
<body>
</body>
</html>
Firebug控制台显示一些错误:
NS_ERROR_DOM_BAD_URI: Access to restricted URI denied
发生了好几次。这个存在一次:
Error: Load timeout for modules: text!templates/navbar.html_unnormalized3,text!templates/footer.html_unnormalized5,text!templates/blockbrowser.html_unnormalized7,text!templates/login.html_unnormalized9,text!templates/sidebar.html_unnormalized11,text!templates/vehiclesidebar.html_unnormalized13,text!templates/companies.html_unnormalized15,text!templates/companies/companiesDeleteModal.html_unnormalized16,text!templates/companies/companiesAddModal.html_unnormalized17,text!templates/dashboard.html_unnormalized19,text!templates/main_grouped_vehiclelist.html_unnormalized20,text!templates/main_errorlist.html_unnormalized21,text!templates/main_servicelist_details.html_unnormalized22,text!templates/dashboard/dashboardMessageModal.html_unnormalized23,text!templates/dashboard/dashboardDoneModal.html_unnormalized24,text!templates/workshops.html_unnormalized26,text!templates/workshops/workshopsDeleteModal.html_unnormalized27,text!templates/workshops/workshopsAddModal.html_unnormalized28,text!templates/vehicles.html_unnormalized30,text!templates/vehiclesMessageModal.html_unnormalized31,text!templates/vehiclesDeleteModal.html_unnormalized32,text!templates/users.html_unnormalized34,text!templates/usersDeleteModal.html_unnormalized35,text!templates/vehicletrips.html_unnormalized37,text!templates/infowindow/obdinfowindow.html_unnormalized38,text!templates/infowindow/tripsummarylegend.html_unnormalized39,text!templates/infowindow/tripsummarycontent.html_unnormalized40,text!templates/infowindow/tripVehiclestatuslegend.html_unnormalized41,text!templates/infowindow/tripVehiclestatuscontent.html_unnormalized42,text!templates/addvehicle.html_unnormalized46,text!templates/addvehicle/addVehicleConflictModal.html_unnormalized47,text!templates/inBox.html_unnormalized49,text!templates/vehiclesMessageModal.html_unnormalized50,text!templates/vehiclesDeleteModal.html_unnormalized51,text!templates/vehicleerrors.html_unnormalized53,text!templates/vehicledetails/errors/errorSingleTable.html_unnormalized54,text!templates/vehicledata.html_unnormalized56,text!templates/vehicledetails/data/vehicledata.html_unnormalized57,text!templates/vehicledetails/data/vehicleadditionaldata.html_unnormalized58,text!templates/vehicledetails/data/vehiclemileage.html_unnormalized59,text!templates/vehicledetails/data/changeDongleModal.html_unnormalized60,text!templates/vehicledetails/data/dropDongleModal.html_unnormalized61,text!templates/vehicledetails/data/ECDModal.html_unnormalized62,text!templates/addvehicle/addVehicleConflictModal.html_unnormalized63,text!templates/vehicleservice.html_unnormalized65,text!templates/vehicledetails/service/levelTwoserviceinformation.html_unnormalized66,text!templates/vehicledetails/service/nextservice.html_unnormalized67,text!templates/vehicledetails/service/servicereminders.html_unnormalized68,text!templates/dashboard/dashboardMessageModal.html_unnormalized69,text!templates/dashboard/dashboardDoneModal.html_unnormalized70,text!templates/adduser.html_unnormalized72,text!templates/edituser.html_unnormalized74,text!templates/edituserForm.html_unnormalized75,text!templates/editprofile.html_unnormalized77,text!templates/appdownload.html_unnormalized79,text!templates/navbar.html,text!templates/companies/companytable.html,text!templates/main_servicelist.html,text!templates/workshops/workshoptable.html,text!templates/vehicles/vehicletable.html,text!templates/users/usertable.html,text!templates/vehicledetails/trips/tripstable.html,text!templates/messages/messagestable.html,text!templates/vehicledetails/errors/errortable.html,text!templates/error.html,text!templates/enginecode.html,text!templates/vehicledetails/data/vehicleAdditionalDataUpcomingServices.html,text!templates/addvehicle.html
http://requirejs.org/docs/errors.html#timeout