ember-auth icon indicating copy to clipboard operation
ember-auth copied to clipboard

Errors when calling Ember.run during Qunit testing

Open mykoweb opened this issue 12 years ago • 3 comments

When calling Ember.run during test setup, I get the following error:

Error while loading route: TypeError: 'null' is not an object (evaluating 'get$(get$(this, 'auth'), '_session').retrieve')
    at http://127.0.0.1:57645/assets/ember-auth-module-rememberable.js?body=1:68
    at http://127.0.0.1:57645/assets/ember-auth-module-rememberable.js?body=1:41
    at http://127.0.0.1:57645/assets/ember-auth-module-rememberable.js?body=1:84
    at invokeCallback (http://127.0.0.1:57744/assets/ember.js?body=1:9428)
    at publish (http://127.0.0.1:57744/assets/ember.js?body=1:9098)
    at publishFulfillment (http://127.0.0.1:57744/assets/ember.js?body=1:9518)
    at http://127.0.0.1:57744/assets/ember.js?body=1:5651
    at http://127.0.0.1:57744/assets/ember.js?body=1:5742
    at http://127.0.0.1:57744/assets/ember.js?body=1:5781
    at http://127.0.0.1:57744/assets/ember.js?body=1:6182
    at http://127.0.0.1:57744/assets/integration/happy_test.js?body=1:3
    at http://127.0.0.1:57744/assets/teaspoon-qunit.js?body=1:178
    at http://127.0.0.1:57744/assets/teaspoon-qunit.js?body=1:360
    at process (http://127.0.0.1:57744/assets/teaspoon-qunit.js?body=1:1455)
    at http://127.0.0.1:57744/assets/teaspoon-qunit.js?body=1:481

I don't know enough about the Ember Run Loop to properly fix this, but a quick hack involves just handling the case when '_session' is null.

You can put the following in your Qunit test_helper.js:

Ember.Auth.RememberableAuthModule.reopen({
  retrieveToken: function () {
    var session = get$(get$(this, 'auth'), '_session');
    return session ? session.retrieve('ember-auth-rememberable') : null;
  }
});

This works for me for now, but a better fix would definitely be welcome. Thanks.

mykoweb avatar Feb 01 '14 19:02 mykoweb

Thanks for the fix!

I'm now getting a similar error in ember-auth-module-ember-data:

Error while loading route: TypeError: Cannot read property 'serialize' of undefined
    at get$.reopen.ajax (http://localhost:3000/assets/ember-auth-module-ember-data.js?body=1:51:76)

Any idea on how to fix this?

mgraham avatar May 10 '14 15:05 mgraham

Hi Michael,

Sorry about not responding sooner. I've switched to using ember-simple-auth. Although I really liked the initial work on ember-auth, it seems to be quite inactive these days. Good luck and hope you didn't spend too much time on this.

Best,

Mike

On Sat, May 10, 2014 at 8:18 AM, Michael Graham [email protected]:

Thanks for the fix!

I'm now getting a similar error in ember-auth-module-ember-data:

Error while loading route: TypeError: Cannot read property 'serialize' of undefined at get$.reopen.ajax (http://localhost:3000/assets/ember-auth-module-ember-data.js?body=1:51:76)

Any idea on how to fix this?

— Reply to this email directly or view it on GitHubhttps://github.com/heartsentwined/ember-auth/issues/136#issuecomment-42744592 .

mykoweb avatar May 16 '14 05:05 mykoweb

Thanks, Mike!

mgraham avatar May 19 '14 04:05 mgraham