且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用 $httpBackend 对 AngularJS 进行单元测试会给出“错误:意外请求".

更新时间:2021-08-30 22:38:10

我发现了它是什么.我的 register_user() 函数引用了 $scope.user,它被设置为一个未定义的变量:userJohnDoeCredentials(我有一个不同的变量名用于我之前的测试).

I found out what it was. my register_user() function was referencing $scope.user, which was being set to an undefined variable: userJohnDoeCredentials (a different variable name I had used for my previous test).

不知道为什么我的 IDE 没有抱怨我引用了一个未定义的变量,而且它通过了我所有的 jslint 测试,所以这也很奇怪,但是嗯.它是固定的:D 只有现在我可以得到模拟请求来返回我想要的东西......

Not sure why my IDE wasn't complaining about me referencing an undefined variable, and it was passing all of my jslint tests, so that's strange too, but meh. It's fixed :D Only if now I could get the mock request to return what I want it to...