Open schinkowitch opened 9 years ago
I've tried to reproduce the error, but couldn't. Try running bower install --save stormpath-sdk-angularjs
again. There might have been an issue when you were downloading from bower. Also, there might be more to the stack trace than what you are finding, and adding files manually won't solve the issue. Since you're not too far head in the tutorial, I'd simply try to go through the instructions and install the dependencies again.
I started the tutorial from scratch, and followed the steps carefully. After performing the step: Add Stormpath to the Angular Application, the client tests still fail when executed from the command line (grunt test:client) .
Here is the error with the full stack trace:
PhantomJS 1.9.8 (Mac OS X 0.0.0) Controller: MainCtrl should attach a list of things to the scope FAILED Error: [$injector:modulerr] Failed to instantiate module dashboardApp due to: Error: [$injector:modulerr] Failed to instantiate module stormpath due to: Error: [$injector:nomod] Module 'stormpath' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument. http://errors.angularjs.org/1.4.0/$injector/nomod?p0=stormpath at /Users/aaron/Development/my-angular-project/client/bower_components/angular/angular.js:1955 at ensure (/Users/aaron/Development/my-angular-project/client/bower_components/angular/angular.js:1877) at module (/Users/aaron/Development/my-angular-project/client/bower_components/angular/angular.js:2192) at /Users/aaron/Development/my-angular-project/client/bower_components/angular/angular.js:4338 at forEach (/Users/aaron/Development/my-angular-project/client/bower_components/angular/angular.js:336) at loadModules (/Users/aaron/Development/my-angular-project/client/bower_components/angular/angular.js:4364) at /Users/aaron/Development/my-angular-project/client/bower_components/angular/angular.js:4339 at forEach (/Users/aaron/Development/my-angular-project/client/bower_components/angular/angular.js:336) at loadModules (/Users/aaron/Development/my-angular-project/client/bower_components/angular/angular.js:4364) at createInjector (/Users/aaron/Development/my-angular-project/client/bower_components/angular/angular.js:4248) at workFn (/Users/aaron/Development/my-angular-project/client/bower_components/angular-mocks/angular-mocks.js:2409) http://errors.angularjs.org/1.4.0/$injector/modulerr?p0=stormpath&p1=Error%3A%20%5B%24injector%3Anomod%5D%20Module%20'stormpath'%20is%20not%20available!%20You%20either%20misspelled%20the%20module%20name%20or%20forgot%20to%20load%20it.%20If%20registering%20a%20module%20ensure%20that%20you%20specify%20the%20dependencies%20as%20the%20second%20argument.%0Ahttp%3A%2F%2Ferrors.angularjs.org%2F1.4.0%2F%24injector%2Fnomod%3Fp0%3Dstormpath%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A8080%2Fbase%2Fclient%2Fbower_components%2Fangular%2Fangular.js%3Fa8801ba98c78d07cf4bb6282c977b19635e11eb6%3A1955%0A%20%20%20%20at%20ensure%20(http%3A%2F%2Flocalhost%3A8080%2Fbase%2Fclient%2Fbower_components%2Fangular%2Fangular.js%3Fa8801ba98c78d07cf4bb6282c977b19635e11eb6%3A1877)%0A%20%20%20%20at%20module%20(http%3A%2F%2Flocalhost%3A8080%2Fbase%2Fclient%2Fbower_components%2Fangular%2Fangular.js%3Fa8801ba98c78d07cf4bb6282c977b19635e11eb6%3A2192)%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A8080%2Fbase%2Fclient%2Fbower_components%2Fangular%2Fangular.js%3Fa8801ba98c78d07cf4bb6282c977b19635e11eb6%3A4338%0A%20%20%20%20at%20forEach%20(http%3A%2F%2Flocalhost%3A8080%2Fbase%2Fclient%2Fbower_components%2Fangular%2Fangular.js%3Fa8801ba98c78d07cf4bb6282c977b19635e11eb6%3A336)%0A%20%20%20%20at%20loadModules%20(http%3A%2F%2Flocalhost%3A8080%2Fbase%2Fclient%2Fbower_components%2Fangular%2Fangular.js%3Fa8801ba98c78d07cf4bb6282c977b19635e11eb6%3A4364)%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A8080%2Fbase%2Fclient%2Fbower_components%2Fangular%2Fangular.js%3Fa8801ba98c78d07cf4bb6282c977b19635e11eb6%3A4339%0A%20%20%20%20at%20forEach%20(http%3A%2F%2Flocalhost%3A8080%2Fbase%2Fclient%2Fbower_components%2Fangular%2Fangular.js%3Fa8801ba98c78d07cf4bb6282c977b19635e11eb6%3A336)%0A%20%20%20%20at%20loadModules%20(http%3A%2F%2Flocalhost%3A8080%2Fbase%2Fclient%2Fbower_components%2Fangular%2Fangular.js%3Fa8801ba98c78d07cf4bb6282c977b19635e11eb6%3A4364)%0A%20%20%20%20at%20createInjector%20(http%3A%2F%2Flocalhost%3A8080%2Fbase%2Fclient%2Fbower_components%2Fangular%2Fangular.js%3Fa8801ba98c78d07cf4bb6282c977b19635e11eb6%3A4248)%0A%20%20%20%20at%20workFn%20(http%3A%2F%2Flocalhost%3A8080%2Fbase%2Fclient%2Fbower_components%2Fangular-mocks%2Fangular-mocks.js%3F88564a421ab0312bc0e077aecc890729894fa256%3A2409)%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A8080%2Fbase%2Fnode_modules%2Fkarma-jasmine%2Flib%2Fjasmine.js%3F437512c57124d57f5ec77e2e82bfb4e3cdd15cce%3A1145%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A8080%2Fbase%2Fnode_modules%2Fkarma-jasmine%2Flib%2Fjasmine.js%3F437512c57124d57f5ec77e2e82bfb4e3cdd15cce%3A2177%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A8080%2Fbase%2Fnode_modules%2Fkarma-jasmine%2Flib%2Fjasmine.js%3F437512c57124d57f5ec77e2e82bfb4e3cdd15cce%3A2167 at /Users/aaron/Development/my-angular-project/client/bower_components/angular/angular.js:4362 at forEach (/Users/aaron/Development/my-angular-project/client/bower_components/angular/angular.js:336) at loadModules (/Users/aaron/Development/my-angular-project/client/bower_components/angular/angular.js:4364) at /Users/aaron/Development/my-angular-project/client/bower_components/angular/angular.js:4339 at forEach (/Users/aaron/Development/my-angular-project/client/bower_components/angular/angular.js:336) at loadModules (/Users/aaron/Development/my-angular-project/client/bower_components/angular/angular.js:4364) at createInjector (/Users/aaron/Development/my-angular-project/client/bower_components/angular/angular.js:4248) at workFn (/Users/aaron/Development/my-angular-project/client/bower_components/angular-mocks/angular-mocks.js:2409) http://errors.angularjs.org/1.4.0/$injector/modulerr?p0=dashboardApp&p1=Error%3A%20%5B%24injector%3Amodulerr%5D%20Failed%20to%20instantiate%20module%20stormpath%20due%20to%3A%0AError%3A%20%5B%24injector%3Anomod%5D%20Module%20'stormpath'%20is%20not%20available!%20You%20either%20misspelled%20the%20module%20name%20or%20forgot%20to%20load%20it.%20If%20registering%20a%20module%20ensure%20that%20you%20specify%20the%20dependencies%20as%20the%20second%20argument.%0Ahttp%3A%2F%2Ferrors.angularjs.org%2F1.4.0%2F%24injector%2Fnomod%3Fp0%3Dstormpath%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A8080%2Fbase%2Fclient%2Fbower_components%2Fangular%2Fangular.js%3Fa8801ba98c78d07cf4bb6282c977b19635e11eb6%3A1955%0A%20%20%20%20at%20ensure%20(http%3A%2F%2Flocalhost%3A8080%2Fbase%2Fclient%2Fbower_components%2Fangular%2Fangular.js%3Fa8801ba98c78d07cf4bb6282c977b19635e11eb6%3A1877)%0A%20%20%20%20at%20module%20(http%3A%2F%2Flocalhost%3A8080%2Fbase%2Fclient%2Fbower_components%2Fangular%2Fangular.js%3Fa8801ba98c78d07cf4bb6282c977b19635e11eb6%3A2192)%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A8080%2Fbase%2Fclient%2Fbower_components%2Fangular%2Fangular.js%3Fa8801ba98c78d07cf4bb6282c977b19635e11eb6%3A4338%0A%20%20%20%20at%20forEach%20(http%3A%2F%2Flocalhost%3A8080%2Fbase%2Fclient%2Fbower_components%2Fangular%2Fangular.js%3Fa8801ba98c78d07cf4bb6282c977b19635e11eb6%3A336)%0A%20%20%20%20at%20loadModules%20(http%3A%2F%2Flocalhost%3A8080%2Fbase%2Fclient%2Fbower_components%2Fangular%2Fangular.js%3Fa8801ba98c78d07cf4bb6282c977b19635e11eb6%3A4364)%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A8080%2Fbase%2Fclient%2Fbower_components%2Fangular%2Fangular.js%3Fa8801ba98c78d07cf4bb6282c977b19635e11eb6%3A4339%0A%20%20%20%20at%20forEach%20(http%3A%2F%2Flocalhost%3A8080%2Fbase%2Fclient%2Fbower_components%2Fangular%2Fangular.js%3Fa8801ba98c78d07cf4bb6282c977b19635e11eb6%3A336)%0A%20%20%20%20at%20loadModules%20(http%3A%2F%2Flocalhost%3A8080%2Fbase%2Fclient%2Fbower_components%2Fangular%2Fangular.js%3Fa8801ba98c78d07cf4bb6282c977b19635e11eb6%3A4364)%0A%20%20%20%20at%20createInjector%20(http%3A%2F%2Flocalhost%3A8080%2Fbase%2Fclient%2Fbower_components%2Fangular%2Fangular.js%3Fa8801ba98c78d07cf4bb6282c977b19635e11eb6%3A4248)%0A%20%20%20%20at%20workFn%20(http%3A%2F%2Flocalhost%3A8080%2Fbase%2Fclient%2Fbower_components%2Fangular-mocks%2Fangular-mocks.js%3F88564a421ab0312bc0e077aecc890729894fa256%3A2409)%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A8080%2Fbase%2Fnode_modules%2Fkarma-jasmine%2Flib%2Fjasmine.js%3F437512c57124d57f5ec77e2e82bfb4e3cdd15cce%3A1145%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A8080%2Fbase%2Fnode_modules%2Fkarma-jasmine%2Flib%2Fjasmine.js%3F437512c57124d57f5ec77e2e82bfb4e3cdd15cce%3A2177%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A8080%2Fbase%2Fnode_modules%2Fkarma-jasmine%2Flib%2Fjasmine.js%3F437512c57124d57f5ec77e2e82bfb4e3cdd15cce%3A2167%0Ahttp%3A%2F%2Ferrors.angularjs.org%2F1.4.0%2F%24injector%2Fmodulerr%3Fp0%3Dstormpath%26p1%3DError%253A%2520%255B%2524injector%253Anomod%255D%2520Module%2520'stormpath'%2520is%2520not%2520available!%2520You%2520either%2520misspelled%2520the%2520module%2520name%2520or%2520forgot%2520to%2520load%2520it.%2520If%2520registering%2520a%2520module%2520ensure%2520that%2520you%2520specify%2520the%2520dependencies%2520as%2520the%2520second%2520argument.%250Ahttp%253A%252F%252Ferrors.angularjs.org%252F1.4.0%252F%2524injector%252Fnomod%253Fp0%253Dstormpath%250A%2520%2520%2520%2520at%2520http%253A%252F%252Flocalhost%253A8080%252Fbase%252Fclient%252Fbower_components%252Fangular%252Fangular.js%253Fa8801ba98c78d07cf4bb6282c977b19635e11eb6%253A1955%250A%2520%2520%2520%2520at%2520ensure%2520(http%253A%252F%252Flocalhost%253A8080%252Fbase%252Fclient%252Fbower_components%252Fangular%252Fangular.js%253Fa8801ba98c78d07cf4bb6282c977b19635e11eb6%253A1877)%250A%2520%2520%2520%2520at%2520module%2520(http%253A%252F%252Flocalhost%253A8080%252Fbase%252Fclient%252Fbower_components%252Fangular%252Fangular.js%253Fa8801ba98c78d07cf4bb6282c977b19635e11eb6%253A2192)%250A%2520%2520%2520%2520at%2520http%253A%252F%252Flocalhost%253A8080%252Fbase%252Fclient%252Fbower_components%252Fangular%252Fangular.js%253Fa8801ba98c78d07cf4bb6282c977b19635e11eb6%253A4338%250A%2520%2520%2520%2520at%2520forEach%2520(http%253A%252F%252Flocalhost%253A8080%252Fbase%252Fclient%252Fbower_components%252Fangular%252Fangular.js%253Fa8801ba98c78d07cf4bb6282c977b19635e11eb6%253A336)%250A%2520%2520%2520%2520at%2520loadModules%2520(http%253A%252F%252Flocalhost%253A8080%252Fbase%252Fclient%252Fbower_components%252Fangular%252Fangular.js%253Fa8801ba98c78d07cf4bb6282c977b19635e11eb6%253A4364)%250A%2520%2520%2520%2520at%2520http%253A%252F%252Flocalhost%253A8080%252Fbase%252Fclient%252Fbower_components%252Fangular%252Fangular.js%253Fa8801ba98c78d07cf4bb6282c977b19635e11eb6%253A4339%250A%2520%2520%2520%2520at%2520forEach%2520(http%253A%252F%252Flocalhost%253A8080%252Fbase%252Fclient%252Fbower_components%252Fangular%252Fangular.js%253Fa8801ba98c78d07cf4bb6282c977b19635e11eb6%253A336)%250A%2520%2520%2520%2520at%2520loadModules%2520(http%253A%252F%252Flocalhost%253A8080%252Fbase%252Fclient%252Fbower_components%252Fangular%252Fangular.js%253Fa8801ba98c78d07cf4bb6282c977b19635e11eb6%253A4364)%250A%2520%2520%2520%2520at%2520createInjector%2520(http%253A%252F%252Flocalhost%253A8080%252Fbase%252Fclient%252Fbower_components%252Fangular%252Fangular.js%253Fa8801ba98c78d07cf4bb6282c977b19635e11eb6%253A4248)%250A%2520%2520%2520%2520at%2520workFn%2520(http%253A%252F%252Flocalhost%253A8080%252Fbase%252Fclient%252Fbower_components%252Fangular-mocks%252Fangular-mocks.js%253F88564a421ab0312bc0e077aecc890729894fa256%253A2409)%250A%2520%2520%2520%2520at%2520http%253A%252F%252Flocalhost%253A8080%252Fbase%252Fnode_modules%252Fkarma-jasmine%252Flib%252Fjasmine.js%253F437512c57124d57f5ec77e2e82bfb4e3cdd15cce%253A1145%250A%2520%2520%2520%2520at%2520http%253A%252F%252Flocalhost%253A8080%252Fbase%252Fnode_modules%252Fkarma-jasmine%252Flib%252Fjasmine.js%253F437512c57124d57f5ec77e2e82bfb4e3cdd15cce%253A2177%250A%2520%2520%2520%2520at%2520http%253A%252F%252Flocalhost%253A8080%252Fbase%252Fnode_modules%252Fkarma-jasmine%252Flib%252Fjasmine.js%253F437512c57124d57f5ec77e2e82bfb4e3cdd15cce%253A2167%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A8080%2Fbase%2Fclient%2Fbower_components%2Fangular%2Fangular.js%3Fa8801ba98c78d07cf4bb6282c977b19635e11eb6%3A4362%0A%20%20%20%20at%20forEach%20(http%3A%2F%2Flocalhost%3A8080%2Fbase%2Fclient%2Fbower_components%2Fangular%2Fangular.js%3Fa8801ba98c78d07cf4bb6282c977b19635e11eb6%3A336)%0A%20%20%20%20at%20loadModules%20(http%3A%2F%2Flocalhost%3A8080%2Fbase%2Fclient%2Fbower_components%2Fangular%2Fangular.js%3Fa8801ba98c78d07cf4bb6282c977b19635e11eb6%3A4364)%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A8080%2Fbase%2Fclient%2Fbower_components%2Fangular%2Fangular.js%3Fa8801ba98c78d07cf4bb6282c977b19635e11eb6%3A4339%0A%20%20%20%20at%20forEach%20(http%3A%2F%2Flocalhost%3A8080%2Fbase%2Fclient%2Fbower_components%2Fangular%2Fangular.js%3Fa8801ba98c78d07cf4bb6282c977b19635e11eb6%3A336)%0A%20%20%20%20at%20loadModules%20(http%3A%2F%2Flocalhost%3A8080%2Fbase%2Fclient%2Fbower_components%2Fangular%2Fangular.js%3Fa8801ba98c78d07cf4bb6282c977b19635e11eb6%3A4364)%0A%20%20%20%20at%20createInjector%20(http%3A%2F%2Flocalhost%3A8080%2Fbase%2Fclient%2Fbower_components%2Fangular%2Fangular.js%3Fa8801ba98c78d07cf4bb6282c977b19635e11eb6%3A4248)%0A%20%20%20%20at%20workFn%20(http%3A%2F%2Flocalhost%3A8080%2Fbase%2Fclient%2Fbower_components%2Fangular-mocks%2Fangular-mocks.js%3F88564a421ab0312bc0e077aecc890729894fa256%3A2409)%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A8080%2Fbase%2Fnode_modules%2Fkarma-jasmine%2Flib%2Fjasmine.js%3F437512c57124d57f5ec77e2e82bfb4e3cdd15cce%3A1145%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A8080%2Fbase%2Fnode_modules%2Fkarma-jasmine%2Flib%2Fjasmine.js%3F437512c57124d57f5ec77e2e82bfb4e3cdd15cce%3A2177%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A8080%2Fbase%2Fnode_modules%2Fkarma-jasmine%2Flib%2Fjasmine.js%3F437512c57124d57f5ec77e2e82bfb4e3cdd15cce%3A2167 at /Users/aaron/Development/my-angular-project/client/bower_components/angular/angular.js:4362 at forEach (/Users/aaron/Development/my-angular-project/client/bower_components/angular/angular.js:336) at loadModules (/Users/aaron/Development/my-angular-project/client/bower_components/angular/angular.js:4364) at createInjector (/Users/aaron/Development/my-angular-project/client/bower_components/angular/angular.js:4248) at workFn (/Users/aaron/Development/my-angular-project/client/bower_components/angular-mocks/angular-mocks.js:2409) TypeError: 'undefined' is not an object (evaluating '$httpBackend.flush') at /Users/aaron/Development/my-angular-project/client/app/main/main.controller.spec.js:25 PhantomJS 1.9.8 (Mac OS X 0.0.0): Executed 1 of 1 (1 FAILED) ERROR (0.108 secs / 0.022 secs)
Yes, I got the same error running grunt test:client
, but I think this error has to do with Angular-Fullstack and not Stormpath. Have you tried simply running grunt serve
? That should work.
Yes, grunt serve
works fine. The point is I'm evaluating using Stormpath for a production app and I need to write testable code. I would think this would be important for you all as well.
I've played around with this some more and found that the following steps seem to fix the issue:
1) add
'client/bower_components/stormpath-sdk-angularjs/dist/stormpath-sdk-angularjs.js',
'client/bower_components/stormpath-sdk-angularjs/dist/stormpath-sdk-angularjs.tpls.min.js',
to the files
in karma.conf.js
2) Use Chrome instead of PhantomJS for the browser: browsers: ['Chrome'],
in karma.conf.js
Then you get a more reasonable test failure: Error: Unexpected request: GET /api/users/current Expected GET /api/things
The stormpath-sdk-angular.js uses ES5.1 Function.prototype.bind which doesn't seem to be implemented in PhantomJS. (This is unfortunate when you recommend angular-fullstack and it is the default test browser).
Disclaimer: I don't work for Stormpath and I am a pretty new developer.
Anyway, what you stated about including all the libraries into Karma, is apparently what you need to do to get the tests working initially.
For the second issue, the error seems to be coming from trying to get the route /api/things
, but /api/users/current
(from stormpath-sdk-express) is getting in the way. Both are called when you get to the front page, and both are called when you log in. Anyway, I think that there might be an issue with the test itself, and looking at the tests for the other controllers, you'll see that they are very generic.
Hi @schinkowitch , thank you for reporting this. At the moment we don't have a recommendation for a testing framework, so take anything you see created by Angular-Fullstack is merely an example. Please note that this module is still beta.
Perhaps you could use the ES5 shim with Phantom?
Regarding the 'Unexpected request' error, I believe that is coming from Angular's mock $http service
Hopefully these comments help, In lieu of formal instructions for testing.
Ok, thanks. Using the ES5 shim with PhantomJS will probably work. I got the test to run on PhantomJS by using Mozilla's Polyfill here.
The "Error: Unexpected request: GET /api/users/current" test failure is reasonable as the sdk is checking to see if the user is logged in. It's a one line fix in the test.
Hi @schinkowitch, what was the "one line fix..." that resolved this issue for you?
As soon as I add stormpath and stormpath.templates as application dependencies, all but a few of my tests fail with that same error: "Error: Unexpected request:".... and it is because SP is checking to see if the user is loogged-in. But my tests are not expecting these calls.
Can you share the one-line fix that worked for you in your tests?
Actually, I was able to figure it out:
$httpBackend.expectGET(CURRENT_USER_URI).respond(200, {});
Note: the angular fullstack generator has dropped support for vanilla JS in 3.x, so when following the guide, you need to install the generator with:
npm install -g generator-angular-fullstack@2.1.1
Following the guide here: http://docs.stormpath.com/angularjs/guide/configure_angular.html
After performing the step: Add Stormpath to the Angular Application, the client tests (grunt test:client) fail with the error:
PhantomJS 1.9.8 (Mac OS X 0.0.0) Controller: MainCtrl should attach a list of things to the scope FAILED Error: [$injector:modulerr] Failed to instantiate module dashboardApp due to: Error: [$injector:modulerr] Failed to instantiate module stormpath.templates due to: Error: [$injector:nomod] Module 'stormpath.templates' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument. http://errors.angularjs.org/1.4.0/$injector/nomod?p0=stormpath.templates
I tried explicitly adding 'client/bower_components/stormpath-sdk-angularjs/dist/stormpath-sdk-angularjs.js', 'client/bower_components/stormpath-sdk-angularjs/dist/stormpath-sdk-angularjs.tpls.js', to files in karma.conf.js but then I get the error: PhantomJS 1.9.8 (Mac OS X 0.0.0) Controller: MainCtrl should attach a list of things to the scope FAILED TypeError: 'undefined' is not a function (evaluating 'encoder.encode.bind(encoder)') at FormEncoderService (/Users/aaron/Development/test-1/client/bower_components/stormpath-sdk-angularjs/dist/stormpath-sdk-angularjs.js:1095) at formEncoderServiceFactory (/Users/aaron/Development/test-1/client/bower_components/stormpath-sdk-angularjs/dist/stormpath-sdk-angularjs.js:1196)