Skip to content
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

isSpecRunning() fails on TypeError: currentSpec.queue is undefined #25

Closed
thisgeek opened this issue Feb 23, 2014 · 2 comments
Closed

Comments

@thisgeek
Copy link

This seems to occur if:

  1. you use karma-jasmine 0.2.1, which upgraded to Jasmine 2
  2. you call inject inside a spec function.
it('unfortunately throws a TypeError', function () {
   inject(function (aService) {
     // code...
   });
});
TypeError: Cannot read property 'running' of undefined
    at isSpecRunning (angular-mocks.js:1923:65)
    at window.inject.angular.mock.inject (angular-mocks.js:2087:12)
    ...

You can work around it by passing the result of inject directly to the it call.

it('works as expected', inject(function (aService) {
   // code...
}));
@thisgeek
Copy link
Author

The issue could possibly be in angular-mocks.

Here's how currentSpec is set:

beforeEach(function() {
  currentSpec = this;
});

For Jasmine 2, as near as I can tell, the function passed to beforeEach() is no longer bound to a jasmine instance. (Without binding, it seems like this is now the global object.)

@thisgeek
Copy link
Author

Fixed in angular/angular.js#6014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant