-
Notifications
You must be signed in to change notification settings - Fork 233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Presence of ng-token-auth causes problems in controller test #45
Comments
I got my test to run in the following way: http://stackoverflow.com/a/26244247/199712 But it does feel kind of wrong to just entirely mock the module away when I don't have to do that with any other modules I'm including. Again, I don't know if this is something specific to ng-token-auth that needs to be fixed with ng-token-auth or if it's not. Sorry for the distraction if it's not. Any insights appreciated. |
@jasonswett - I'll look into this. I haven't run into this issue in my test suite, but I'll add a similar test and see if I can reproduce the issue. |
@lynndylanhurley Okay, thanks. Do you have any publicly available code from an app that uses ng-token-auth and has Angular controller tests? I could only find the Rails portion of your ng-token-auth demo, which didn't seem to have the client-side code in it. |
I've only been using functional unit tests up to this point. They can all be found here. Note how the I'm also working on setting up an E2E suite using Protractor, but it's been a challenge to get working with Travis CI / Sauce Labs, and I haven't gotten very far. But I don't have any controller tests that look like yours. I'll create one ASAP, and I'll let you know what I find. |
Oh, and the client code from the demo is actually included in this repo. Follow these instructions (under the Development section) to run the client demo. I eventually want to build an E2E test suite against the demo. That is why the code is bundled here rather than in a separate repo. |
Okay, thanks. I think we might actually be talking about two different things. It looks like you're talking about tests that test the ng-token-auth module itself, but I'm talking about tests that test an Angular controller within an application that uses ng-token-auth. Hopefully that makes sense. |
No I totally get it - I don't have any tests like that yet. I'll create one, and I'll let you know what I find. |
My bad - I see now that I was the one who was misunderstanding. Sounds good. Curious to hear what you find. |
@jasonswett - I was able to add a controller test without any issues. There must be some component to this issue that we're not seeing. The error suggests that |
Knowing it's possible to have a problem-free controller test helps a lot. Now I know the problem is something within my project as opposed to something inside of ng-token-auth. Let me spin up a clean new project and only put ng-token-auth on it. A controller test should work there. Then I'll gradually add my other stuff at see at what point it stops working. So I think this issue is a non-issue as it pertains to ng-token-auth. If I find something else that does seem like a legitimate issue, I'll open a new, more specific issue for it. |
And thanks again for the help |
No problem @jasonswett! Is your project up on github? Maybe I can help debug. |
Didn't see your comment until just now. Here's the project: https://github.com/jasonswett/lunch_hub/tree/development |
Hmm, I'm still having the problem even with a totally blank Angular project. Maybe I just don't know how to properly initialize the |
Woops, meant to link: https://github.com/jasonswett/ng-test |
I'll pull down your project and see if I can diagnose this. |
Thanks. Jason Swett On Oct 21, 2014, at 7:52 PM, Lynn Dylan Hurley [email protected] wrote:
|
@jasonswett - looks like there was something going on with the After upgrading to ng-token-auth |
Awesome!!! Thank you so much. My test is actually passing on my end, so I'm all set. |
I was using v0.0.23 and got the error. |
I had the same issue but I don't think it's an ng-token-auth issue. If you look at https://github.com/lynndylanhurley/ng-token-auth/blob/master/src/ng-token-auth.coffee you can see that all the |
Yeah gotcha, I copied the dist Ng-token-auth.js file from a new got clone over the top of the bower installed version and it works. Thanks Sent from my iPhone
|
I assume I'm just doing something wrong here.
When I try to write an Angular controller test, I get the following error:
TypeError: 'undefined' is not a function (evaluating 'this.handlePostMessage.bind(this)') at /Users/jasonswett/projects/ben_franklin_labs/lunch_hub/client/bower_components/ng-token-auth/dist/ng-token-auth.js:97
Is there some specific extra step I have to take to get ng-token-auth not to cause this error? I'm including other custom modules and those seem to work fine, so I'm kind of at a loss.
I'm submitting this as an issue rather than just a StackOverflow question or something in case it is actually a legitimate issue that needs to be addressed.
The text was updated successfully, but these errors were encountered: