Javascript RequireJS错误:超时

Javascript RequireJS错误:超时,javascript,requirejs,jasmine,Javascript,Requirejs,Jasmine,我正在用Jasmine测试一个JavaScript项目。一切都进行得很顺利,但突然间一切都不起作用了,尽管我记不起改变了什么。我得到这个错误: Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL. 错误发生在这段代码中: describe("DesktopRouter", function(){ var router;

我正在用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>
发生多次。这个曾经存在过:

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

文件“DesktopRouter”是否存在?最好使用绝对路径而不是相对路径。是的,它存在。我正在测试四个文件。其中一个工作正常。但我没有改变任何有关项目结构的内容。检查您的浏览器控制台是否存在404个错误?我在上面的firebug控制台中添加了错误,但我知道这些错误并不意味着什么,现在已经太晚了,但我相信RequireJS文本插件通过让RequireJS知道如何读取HTML文件来帮助解决这个问题:
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