结果消息:错误:[$ injector:modulerr] http://errors.angularjs.org/1.5.3/$injector/modulerr?p0=homeIndex&p1=

时间:2016-04-20 18:10:27

标签: javascript angularjs asp.net-mvc jasmine chutzpah

目前,我正在尝试使用此代码进行单元测试:

BoostrapAngularJsEf

我的“home-index Tests-> dataService->可以加载主题”失败了,给我这个错误:

Test Name:  home-index Tests-> dataService-> can load topics
Test FullName:  c:\Workspace\9-m8\messageboard.tests\clienttests\homeindextests.js::home-index tests-> dataservice->::can load topics
Test Source:    c:\Workspace\9-m8\messageboard.tests\clienttests\homeindextests.js : line 51
Test Outcome:   Failed
Test Duration:  0:00:00.014

Result Message: Error: [$injector:modulerr] http://errors.angularjs.org/1.5.3/$injector/modulerr?p0=homeIndex&p1=%5B%24injector%3Amodulerr%5D%20http%3A%2F%2Ferrors.angularjs.org%2F1.5.3%2F%24injector%2Fmodulerr%3Fp0%3DngResource%26p1%3D%255B%2524injector%253Anomod%255D%2520http%253A%252F%252Ferrors.angularjs.org%252F1.5.3%252F%2524injector%252Fnomod%253Fp0%253DngResource%250A%2509at%2520file%253A%252F%252F%252Fc%253A%252Fcygwin64%252Ftmp%252F9-m8%252Fmessageboard%252Fscripts%252Fangular.min.js%253A25%253A159%250A%2509at%2520b%2520(file%253A%252F%252F%252Fc%253A%252Fcygwin64%252Ftmp%252F9-m8%252Fmessageboard%252Fscripts%252Fangular.min.js%253A24%253A212)%250A%2509at%2520file%253A%252F%252F%252Fc%253A%252Fcygwin64%252Ftmp%252F9-m8%252Fmessageboard%252Fscripts%252Fangular.min.js%253A24%253A627%250A%2509at%2520file%253A%252F%252F%252Fc%253A%252Fcygwin64%252Ftmp%252F9-m8%252Fmessageboard%252Fscripts%252Fangular.min.js%253A39%253A289%250A%2509at%2520q%2520(file%253A%252F%252F%252Fc%253A%252Fcygwin64%252Ftmp%252F9-m8%252Fmessageboard%252Fscripts%252Fangular.min.js%253A7%253A359)%250A%2509at%2520g%2520(file%253A%252F%252F%252Fc%253A%252Fcygwin64%252Ftmp%252F9-m8%252Fmessageboard%252Fscripts%252Fangular.min.js%253A39%253A136)%250A%2509at%2520file%253A%252F%252F%252Fc%253A%252Fcygwin64%252Ftmp%252F9-m8%252Fmessageboard%252Fscripts%252Fangular.min.js%253A39%253A305%250A%2509at%2520q%2520(file%253A%252F%252F%252Fc%253A%252Fcygwin64%252Ftmp%252F9-m8%252Fmessageboard%252Fscripts%252Fangular.min.js%253A7%253A359)%250A%2509at%2520g%2520(file%253A%252F%252F%252Fc%253A%252Fcygwin64%252Ftmp%252F9-m8%252Fmessageboard%252Fscripts%252Fangular.min.js%253A39%253A136)%250A%2509at%2520eb%2520(file%253A%252F%252F%252Fc%253A%252Fcygwin64%252Ftmp%252F9-m8%252Fmessageboard%252Fscripts%252Fangular.min.js%253A43%253A165)%250A%2509at%2520workFn%2520(file%253A%252F%252F%252Fc%253A%252Fcygwin64%252Ftmp%252F9-m8%252Fmessageboard%252Fscripts%252Fangular-mocks.js%253A2922%253A60)%250A%2509at%2520attemptSync%2520(file%253A%252F%252F%252FC%253A%252FUSERS%252FPSALM3_3%252FAPPDATA%252FLOCAL%252FMICROSOFT%252FVISUALSTUDIO%252F12.0%252FEXTENSIONS%252FQLMJ24GW.FII%252FTestFiles%252Fjasmine%252Fv2%252Fjasmine.js%253A1886%253A28)%250A%2509at%2520run%2520(file%253A%252F%252F%252FC%253A%252FUSERS%252FPSALM3_3%252FAPPDATA%252FLOCAL%252FMICROSOFT%252FVISUALSTUDIO%252F12.0%252FEXTENSIONS%252FQLMJ24GW.FII%252FTestFiles%252Fjasmine%252Fv2%252Fjasmine.js%253A1874%253A20)%250A%2509at%2520execute%2520(file%253A%252F%252F%252FC%253A%252FUSERS%252FPSALM3_3%252FAPPDATA%252FLOCAL%252FMICROSOFT%252FVISUALSTUDIO%252F12.0%252FEXTENSIONS%252FQLMJ24GW.FII%252FTestFiles%252Fjasmine%252Fv2%252Fjasmine.js%253A1859%253A13)%250A%2509at%2520queueRunnerFactory%2520(file%253A%252F%252F%252FC%253A%252FUSERS%252FPSALM3_3%252FAPPDATA%252FLOCAL%252FMICROSOFT%252FVISUALSTUDIO%252F12.0%252FEXTENSIONS%252FQLMJ24GW.FII%252FTestFiles%252Fjasmine%252Fv2%252Fjasmine.js%253A697%253A42)%250A%2509at%2520execute%2520(file%253A%252F%252F%252FC%253A%252FUSERS%252FPSALM3_3%252FAPPDATA%252FLOCAL%252FMICROSOFT%252FVISUALSTUDIO%252F12.0%252FEXTENSIONS%252FQLMJ24GW.FII%252FTestFiles%252Fjasmine%252Fv2%252Fjasmine.js%253A359%253A28)%250A%2509at%2520fn%2520(file%253A%252F%252F%252FC%253A%252FUSERS%252FPSALM3_3%252FAPPDATA%252FLOCAL%252FMICROSOFT%252FVISUALSTUDIO%252F12.0%252FEXTENSIONS%252FQLMJ24GW.FII%252FTestFiles%252Fjasmine%252Fv2%252Fjasmine.js%253A2479%253A44)%250A%2509at%2520attemptAsync%2520(file%253A%252F%252F%252FC%253A%252FUSERS%252FPSALM3_3%252FAPPDATA%252FLOCAL%252FMICROSOFT%252FVISUALSTUDIO%252F12.0%252FEXTENSIONS%252FQLMJ24GW.FII%252FTestFiles%252Fjasmine%252Fv2%252Fjasmine.js%253A1916%253A28)%250A%2509at%2520run%2520(file%253A%252F%252F%252FC%253A%252FUSERS%252FPSALM3_3%252FAPPDATA%252FLOCAL%252FMICROSOFT%252FVISUALSTUDIO%252F12.0%252FEXTENSIONS%252FQLMJ24GW.FII%252FTestFiles%252Fjasmine%252Fv2%252Fjasmine.js%253A1871%253A21)%250A%2509at%2520execute%2520(file%253A%252F%252F%252FC%253A%252FUSERS%252FPSALM3_3%252FAPPDATA%252FLOCAL%252FMICROSOFT%252FVISUALSTUDIO%252F12.0%252FEXTENSIONS%252FQLMJ24GW.FII%252FTestFiles%252Fjasmine%252Fv2%252Fjasmine.js%253A1859%253A13)%250A%2509at%2520queueRunnerFactory%2520(file%253A%252F%252F%252FC%253A%252FUSERS%252FPSALM3_3%252FAPPDATA%252FLOCAL%252FMICROSOFT%252FVISUALSTUDIO%252F12.0%252FEXTENSIONS%252FQLMJ24GW.FII%252FTestFiles%252Fjasmine%252Fv2%252Fjasmine.js%253A697%253A42)%250A%2509at%2520fn%2520(file%253A%252F%252F%252FC%253A%252FUSERS%252FPSALM3_3%252FAPPDATA%252FLOCAL%252FMICROSOFT%252FVISUALSTUDIO%252F12.0%252FEXTENSIONS%252FQLMJ24GW.FII%252FTestFiles%252Fjasmine%252Fv2%252Fjasmine.js%253A2464%253A31)%250A%2509at%2520attemptAsync%2520(file%253A%252F%252F%252FC%253A%252FUSERS%252FPSALM3_3%252FAPPDATA%252FLOCAL%252FMICROSOFT%252FVISUALSTUDIO%252F12.0%252FEXTENSIONS%252FQLMJ24GW.FII%252FTestFiles%252Fjasmine%252Fv2%252Fjasmine.js%253A1916%253A28)%250A%2509at%2520run%2520(file%253A%252F%252F%252FC%253A%252FUSERS%252FPSALM3_3%252FAPPDATA%252FLOCAL%252FMICROSOFT%252FVISUALSTUDIO%252F12.0%252FEXTENSIONS%252FQLMJ24GW.FII%252FTestFiles%252Fjasmine%252Fv2%252Fjasmine.js%253A1871%253A21)%250A%2509at%2520execute%2520(file%253A%252F%252F%252FC%253A%252FUSERS%252FPSALM3_3%252FAPPDATA%252FLOCAL%252FMICROSOFT%252FVISUALSTUDIO%252F12.0%252FEXTENSIONS%252FQLMJ24GW.FII%252FTestFiles%252Fjasmine%252Fv2%252Fjasmine.js%253A1859%253A13)%250A%2509at%2520queueRunnerFactory%2520(file%253A%252F%252F%252FC%253A%252FUSERS%252FPSALM3_3%252FAPPDATA%252FLOCAL%252FMICROSOFT%252FVISUALSTUDIO%252F12.0%252FEXTENSIONS%252FQLMJ24GW.FII%252FTestFiles%252Fjasmine%252Fv2%252Fjasmine.js%253A697%253A42)%250A%2509at%2520fn%2520(file%253A%252F%252F%252FC%253A%252FUSERS%252FPSALM3_3%252FAPPDATA%252FLOCAL%252FMICROSOFT%252FVISUALSTUDIO%252F12.0%252FEXTENSIONS%252FQLMJ24GW.FII%252FTestFiles%252Fjasmine%252Fv2%252Fjasmine.js%253A2464%253A31)%250A%2509at%2520attemptAsync%2520(file%253A%252F%252F%252FC%253A%252FUSERS%252FPSALM3_3%252FAPPDATA%252FLOCAL%252FMICROSOFT%252FVISUALSTUDIO%252F12.0%252FEXTENSIONS%252FQLMJ24GW.FII%252FTestFiles%252Fjasmine%252Fv2%252Fjasmine.js%253A1916%253A28)%250A%2509at%2520run%2520(file%253A%252F%252F%252FC%253A%252FUSERS%252FPSALM3_3%252FAPPDATA%252FLOCAL%252FMICROSOFT%252FVISUALSTUDIO%252F12.0%252FEXTENSIONS%252FQLMJ24GW.FII%252FTestFiles%252Fjasmine%252Fv2%252Fjasmine.js%253A1871%253A21)%250A%2509at%2520execute%2520(file%253A%252F%252F%252FC%253A%252FUSERS%252FPSALM3_3%252FAPPDATA%252FLOCAL%252FMICROSOFT%252FVISUALSTUDIO%252F12.0%252FEXTENSIONS%252FQLMJ24GW.FII%252FTestFiles%252Fjasmine%252Fv2%252Fjasmine.js%253A1859%253A13)%250A%2509at%2520queueRunnerFactory%2520(file%253A%252F%252F%252FC%253A%252FUSERS%252FPSALM3_3%252FAPPDATA%252FLOCAL%252FMICROSOFT%252FVISUALSTUDIO%252F12.0%252FEXTENSIONS%252FQLMJ24GW.FII%252FTestFiles%252Fjasmine%252Fv2%252Fjasmine.js%253A697%253A42)%250A%2509at%2520execute%2520(file%253A%252F%252F%252FC%253A%252FUSERS%252FPSALM3_3%252FAPPDATA%252FLOCAL%252FMICROSOFT%252FVISUALSTUDIO%252F12.0%252FEXTENSIONS%252FQLMJ24GW.FII%252FTestFiles%252Fjasmine%252Fv2%252Fjasmine.js%253A2326%253A25)%250A%2509at%2520execute%2520(file%253A%252F%252F%252FC%253A%252FUSERS%252FPSALM3_3%252FAPPDATA%252FLOCAL%252FMICROSOFT%252FVISUALSTUDIO%252F12.0%252FEXTENSIONS%252FQLMJ24GW.FII%252FTestFiles%252Fjasmine%252Fv2%252Fjasmine.js%253A757%253A24)%250A%2509at%2520initializeJasmine%2520(file%253A%252F%252F%252FC%253A%252FUSERS%252FPSALM3_3%252FAPPDATA%252FLOCAL%252FMICROSOFT%252FVISUALSTUDIO%252F12.0%252FEXTENSIONS%252FQLMJ24GW.FII%252FTestFiles%252Fjasmine%252Fv2%252Fboot.js%253A122%253A24)%250A%2509at%2520onload%2520(file%253A%252F%252F%252Fc%253A%252Fcygwin64%252Ftmp%252F9-m8%252Fmessageboard.tests%252Fclienttests%252F_Chutzpah.51ccb332480381c19990dff5a53d6901.test.html%253A60%253A45)%0A%09at%20file%3A%2F%2F%2Fc%3A%2Fcygwin64%2Ftmp%2F9-m8%2Fmessageboard%2Fscripts%2Fangular.min.js%3A40%3A98%0A%09at%20q%20(file%3A%2F%2F%2Fc%3A%2Fcygwin64%2Ftmp%2F9-m8%2Fmessageboard%2Fscripts%2Fangular.min.js%3A7%3A359)%0A%09at%20g%20(file%3A%2F%2F%2Fc%3A%2Fcygwin64%2Ftmp%2F9-m8%2Fmessageboard%2Fscripts%2Fangular.min.js%3A39%3A136)%0A%09at%20file%3A%2F%2F%2Fc%3A%2Fcygwin64%2Ftmp%2F9-m8%2Fmessageboard%2Fscripts%2Fangular.min.js%3A39%3A305%0A%09at%20q%20(file%3A%2F%2F%2Fc%3A%2Fcygwin64%2Ftmp%2F9-m8%2Fmessageboard%2Fscripts%2Fangular.min.js%3A7%3A359)%0A%09at%20g%20(file%3A%2F%2F%2Fc%3A%2Fcygwin64%2Ftmp%2F9-m8%2Fmessageboard%2Fscripts%2Fangular.min.js%3A39%3A136)%0A%09at%20eb%20(file%3A%2F%2F%2Fc%3A%2Fcygwin64%2Ftmp%2F9-m8%2Fmessageboard%2Fscripts%2Fangular.min.js%3A43%3A165)%0A%09at%20workFn%20(file%3A%2F%2F%2Fc%3A%2Fcygwin64%2Ftmp%2F9-m8%2Fmessageboard%2Fscripts%2Fangular-mocks.js%3A2922%3A60)%0A%09at%20attemptSync%20(file%3A%2F%2F%2FC%3A%2FUSERS%2FPSALM3_3%2FAPPDATA%2FLOCAL%2FMICROSOFT%2FVISUALSTUDIO%2F12.0%2FEXTENSIONS%2FQLMJ24GW.FII%2FTestFiles%2Fjasmine%2Fv2%2Fjasmine.js%3A1886%3A28)%0A%09at%20run%20(file%3A%2F%2F%2FC%3A%2FUSERS%2FPSALM3_3%2FAPPDATA%2FLOCAL%2FMICROSOFT%2FVISUALSTUDIO%2F12.0%2FEXTENSIONS%2FQLMJ24GW.FII%2FTestFiles%2Fjasmine%2Fv2%2Fjasmine.js%3A1874%3A20)%0A%09at%20execute%20(file%3A%2F%2F%2FC%3A%2FUSERS%2FPSALM3_3%2FAPPDATA%2FLOCAL%2FMICROSOFT%2FVISUALSTUDIO%2F12.0%2FEXTENSIONS%2FQLMJ24GW.FII%2FTestFiles%2Fjasmine%2Fv2%2Fjasmine.js%3A1859%3A13)%0A%09at%20queueRunnerFactory%20(file%3A%2F%2F%2FC%3A%2FUSERS%2FPSALM3_3%2FAPPDATA%2FLOCAL%2FMICROSOFT%2FVISUALSTUDIO%2F12.0%2FEXTENSIONS%2FQLMJ24GW.FII%2FTestFiles%2Fjasmine%2Fv2%2Fjasmine.js%3A697%3A42)%0A%09at%20execute%20(file%3A%2F%2F%2FC%3A%2FUSERS%2FPSALM3_3%2FAPPDATA%2FLOCAL%2FMICROSOFT%2FVISUALSTUDIO%2F12.0%2FEXTENSIONS%2FQLMJ24GW.FII%2FTestFiles%2Fjasmine%2Fv2%2Fjasmine.js%3A359%3A28)%0A%09at%20fn%20(file%3A%2F%2F%2FC%3A%2FUSERS%2FPSALM3_3%2FAPPDATA%2FLOCAL%2FMICROSOFT%2FVISUALSTUDIO%2F12.0%2FEXTENSIONS%2FQLMJ24GW.FII%2FTestFiles%2Fjasmine%2Fv2%2Fjasmine.js%3A2479%3A44)%0A%09at%20attemptAsync%20(file%3A%2F%2F%2FC%3A%2FUSERS%2FPSALM3_3%2FAPPDATA%2FLOCAL%2FMICROSOFT%2FVISUALSTUDIO%2F12.0%2FEXTENSIONS%2FQLMJ24GW.FII%2FTestFiles%2Fjasmine%2Fv2%2Fjasmine.js%3A1916%3A28)%0A%09at%20run%20(file%3A%2F%2F%2FC%3A%2FUSERS%2FPSALM3_3%2FAPPDATA%2FLOCAL%2FMICROSOFT%2FVISUALSTUDIO%2F12.0%2FEXTENSIONS%2FQLMJ24GW.FII%2FTestFiles%2Fjasmine%2Fv2%2Fjasmine.js%3A1871%3A21)%0A%09at%20execute%20(file%3A%2F%2F%2FC%3A%2FUSERS%2FPSALM3_3%2FAPPDATA%2FLOCAL%2FMICROSOFT%2FVISUALSTUDIO%2F12.0%2FEXTENSIONS%2FQLMJ24GW.FII%2FTestFiles%2Fjasmine%2Fv2%2Fjasmine.js%3A1859%3A13)%0A%09at%20queueRunnerFactory%20(file%3A%2F%2F%2FC%3A%2FUSERS%2FPSALM3_3%2FAPPDATA%2FLOCAL%2FMICROSOFT%2FVISUALSTUDIO%2F12.0%2FEXTENSIONS%2FQLMJ24GW.FII%2FTestFiles%2Fjasmine%2Fv2%2Fjasmine.js%3A697%3A42)%0A%09at%20fn%20(file%3A%2F%2F%2FC%3A%2FUSERS%2FPSALM3_3%2FAPPDATA%2FLOCAL%2FMICROSOFT%2FVISUALSTUDIO%2F12.0%2FEXTENSIONS%2FQLMJ24GW.FII%2FTestFiles%2Fjasmine%2Fv2%2Fjasmine.js%3A2464%3A31)%0A%09at%20attemptAsync%20(file%3A%2F%2F%2FC%3A%2FUSERS%2FPSALM3_3%2FAPPDATA%2FLOCAL%2FMICROSOFT%2FVISUALSTUDIO%2F12.0%2FEXTENSIONS%2FQLMJ24GW.FII%2FTestFiles%2Fjasmine%2Fv2%2Fjasmine.js%3A1916%3A28)%0A%09at%20run%20(file%3A%2F%2F%2FC%3A%2FUSERS%2FPSALM3_3%2FAPPDATA%2FLOCAL%2FMICROSOFT%2FVISUALSTUDIO%2F12.0%2FEXTENSIONS%2FQLMJ24GW.FII%2FTestFiles%2Fjasmine%2Fv2%2Fjasmine.js%3A1871%3A21)%0A%09at%20execute%20(file%3A%2F%2F%2FC%3A%2FUSERS%2FPSALM3_3%2FAPPDATA%2FLOCAL%2FMICROSOFT%2FVISUALSTUDIO%2F12.0%2FEXTENSIONS%2FQLMJ24GW.FII%2FTestFiles%2Fjasmine%2Fv2%2Fjasmine.js%3A1859%3A13)%0A%09at%20queueRunnerFactory%20(file%3A%2F%2F%2FC%3A%2FUSERS%2FPSALM3_3%2FAPPDATA%2FLOCAL%2FMICROSOFT%2FVISUALSTUDIO%2F12.0%2FEXTENSIONS%2FQLMJ24GW.FII%2FTestFiles%2Fjasmine%2Fv2%2Fjasmine.js%3A697%3A42)%0A%09at%20fn%20(file%3A%2F%2F%2FC%3A%2FUSERS%2FPSALM3_3%2FAPPDATA%2FLOCAL%2FMICROSOFT%2FVISUALSTUDIO%2F12.0%2FEXTENSIONS%2FQLMJ24GW.FII%2FTestFiles%2Fjasmine%2Fv2%2Fjasmine.js%3A2464%3A31)%0A%09at%20attemptAsync%20(file%3A%2F%2F%2FC%3A%2FUSERS%2FPSALM3_3%2FAPPDATA%2FLOCAL%2FMICROSOFT%2FVISUALSTUDIO%2F12.0%2FEXTENSIONS%2FQLMJ24GW.FII%2FTestFiles%2Fjasmine%2Fv2%2Fjasmine.js%3A1916%3A28)%0A%09at%20run%20(file%3A%2F%2F%2FC%3A%2FUSERS%2FPSALM3_3%2FAPPDATA%2FLOCAL%2FMICROSOFT%2FVISUALSTUDIO%2F12.0%2FEXTENSIONS%2FQLMJ24GW.FII%2FTestFiles%2Fjasmine%2Fv2%2Fjasmine.js%3A1871%3A21)%0A%09at%20execute%20(file%3A%2F%2F%2FC%3A%2FUSERS%2FPSALM3_3%2FAPPDATA%2FLOCAL%2FMICROSOFT%2FVISUALSTUDIO%2F12.0%2FEXTENSIONS%2FQLMJ24GW.FII%2FTestFiles%2Fjasmine%2Fv2%2Fjasmine.js%3A1859%3A13)%0A%09at%20queueRunnerFactory%20(file%3A%2F%2F%2FC%3A%2FUSERS%2FPSALM3_3%2FAPPDATA%2FLOCAL%2FMICROSOFT%2FVISUALSTUDIO%2F12.0%2FEXTENSIONS%2FQLMJ24GW.FII%2FTestFiles%2Fjasmine%2Fv2%2Fjasmine.js%3A697%3A42)%0A%09at%20execute%20(file%3A%2F%2F%2FC%3A%2FUSERS%2FPSALM3_3%2FAPPDATA%2FLOCAL%2FMICROSOFT%2FVISUALSTUDIO%2F12.0%2FEXTENSIONS%2FQLMJ24GW.FII%2FTestFiles%2Fjasmine%2Fv2%2Fjasmine.js%3A2326%3A25)%0A%09at%20execute%20(file%3A%2F%2F%2FC%3A%2FUSERS%2FPSALM3_3%2FAPPDATA%2FLOCAL%2FMICROSOFT%2FVISUALSTUDIO%2F12.0%2FEXTENSIONS%2FQLMJ24GW.FII%2FTestFiles%2Fjasmine%2Fv2%2Fjasmine.js%3A757%3A24)%0A%09at%20initializeJasmine%20(file%3A%2F%2F%2FC%3A%2FUSERS%2FPSALM3_3%2FAPPDATA%2FLOCAL%2FMICROSOFT%2FVISUALSTUDIO%2F12.0%2FEXTENSIONS%2FQLMJ24GW.FII%2FTestFiles%2Fjasmine%2Fv2%2Fboot.js%3A122%3A24)%0A%09at%20onload%20(file%3A%2F%2F%2Fc%3A%2Fcygwin64%2Ftmp%2F9-m8%2Fmessageboard.tests%2Fclienttests%2F_Chutzpah.51ccb332480381c19990dff5a53d6901.test.html%3A60%3A45) in file:///c:/Workspace/9-m8/messageboard/scripts/angular.min.js (line 40)
        at q (file:///c:/Workspace/9-m8/messageboard/scripts/angular.min.js:7:359)
        at g (file:///c:/Workspace/9-m8/messageboard/scripts/angular.min.js:39:136)
        at eb (file:///c:/Workspace/9-m8/messageboard/scripts/angular.min.js:43:165)
        at workFn (file:///c:/Workspace/9-m8/messageboard/scripts/angular-mocks.js:2922:60)
        at attemptSync (file:///C:/USERS/PSALM3_3/APPDATA/LOCAL/MICROSOFT/VISUALSTUDIO/12.0/EXTENSIONS/QLMJ24GW.FII/TestFiles/jasmine/v2/jasmine.js:1886:28)
Result StackTrace:  at home-index Tests-> dataService-> can load topics in c:\Workspace\9-m8\messageboard.tests\clienttests\homeindextests.js:line 50

这里我更新了我的代码以包含allowGlobals(),因为据我所知,AngularJs 1.5.3不再允许全局控制器声明:

// home-index.js
var homeIndexModule = angular.module("homeIndex", ['ngRoute']);

homeIndexModule.config(["$routeProvider", function ($routeProvider) {
  $routeProvider.allowGlobals(),
  $routeProvider.when("/", {
    controller: "topicsController",
    templateUrl: "/templates/topicsView.html",
  });

  $routeProvider.when("/newmessage", {
    controller: "newTopicController",
    templateUrl: "/templates/newTopicView.html"
  });

  $routeProvider.when("/message/:id", {
    controller: "singleTopicController",
    templateUrl: "/templates/singleTopicView.html"
  });

  $routeProvider.otherwise({ redirectTo: "/" });
}]);

这是我的单元测试代码:

/// <reference path="../scripts/jasmine.js" />
/// <reference path="../../messageboard/scripts/angular.js" />
/// <reference path="../../messageboard/scripts/angular-route.js" />
/// <reference path="../../messageboard/scripts/angular-mocks.js" />
/// <reference path="../../messageboard/js/home-index.js" />

describe("home-index Tests->", function () {

  beforeEach(function () {
    module("homeIndex");
  });

  var $httpBackend;

  beforeEach(inject(function ($injector) {

    // Set up the mock http service responses
    $httpBackend = $injector.get("$httpBackend");
    // backend definition common for all tests
    $httpBackend.when("GET", "/api/v1/topics?includeReplies=true")
      .respond([
        {
          title: "first title",
          body: "some body",
          id: 1,
          created: "20050401"
        },
        {
          title: "second title",
          body: "some body",
          id: 1,
          created: "20050401"
        },
        {
          title: "third title",
          body: "some body",
          id: 1,
          created: "20050401"
        },
      ]);

  }));

  afterEach(function () {
    $httpBackend.verifyNoOutstandingExpectation();
    $httpBackend.verifyNoOutstandingRequest();
  });

  describe("dataService->", function () {

    it("can load topics", inject(function (dataService) {

      expect(dataService.topics).toEqual([]);

      $httpBackend.expectGET("/api/v1/topics?includeReplies=true");
      dataService.getTopics();
      $httpBackend.flush();
      expect(dataService.topics.length).toBeGreaterThan(0);
      expect(dataService.topics.length).toEqual(3);

    }));

  });

到目前为止,我已尝试根据angularjs文档更新我的代码:https://docs.angularjs.org/api/ngMock/service/$httpBackend

此外,我花了很多时间搜索SO和其他帖子,但目前尚未成功解决问题。有没有人有什么建议? TIA。

更新

以下是我的_Layout.cshtml的一部分:

<html lang="en" data-ng-app="@ViewBag.InitModule">

这是InitModule:

@model IEnumerable<MessageBoard.Data.Topic>
@{
  ViewBag.Title = "Home Page";
  ViewBag.InitModule = "homeIndex";
}

更新2:

这是我的单元测试app.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.3.0.0" newVersion="1.3.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="DotNetOpenAuth.AspNet" publicKeyToken="2780ccd10d57b246" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="DotNetOpenAuth.Core" publicKeyToken="2780ccd10d57b246" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

这是chutzpah.json:

{
    "Framework": "jasmine",
    "References": [
        { "Path": "../messageboard/scripts/angular.min.js" },
        { "Path": "../messageboard/scripts/angular-mocks.js" },
        { "Path": "../messageboard/js/myapp.js" },
        { "Path": "../messageboard/js/home-index.js" }
    ],
    "Tests": [ { "Include": "*tests.js", "ExpandReferenceComments": true } ]
}

您可以通过下载此zip来实际访问所有代码:

http://www.sandbox.ca/~rmoore/BootstrapAngularJsEfAzure-master.zip

1 个答案:

答案 0 :(得分:0)

beforeEach()期待回归。 return null;也会奏效。 请改为

  beforeEach(function () {
    return module("homeIndex");
  });

或者,改为:

beforeEach(module("homeIndex"));

享受!