jasmine: Error: 'null' is not an object (evaluating 'currentSpec.expect')
This issue has already been posted on karma-jasmine page, but it is a jasmine issue.
As my test suites grew large (over 1100 specs), I started getting the following error: 'null' is not an object (evaluating 'currentSpec.expect') during test execution (using grunt + karma + karma-jasmine and testing an app written using AngularJS). The error would stop the test execution somewhere around spec #700 and report no details. It would consistently trigger during the subsequent executions. It would only disappear after I removed or disabled a spec (any spec, not necessarilly the previously added one). It seems the problem is simply with the suite being too large.
@Mironor created a fix candidate which fixed this problem for me. If you could include it in the next 2.x version of Jasmine or fix this total blocker in some other way, I’d be much obliged.
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Comments: 18 (6 by maintainers)
So far I’m unable to isolate the source - the issue disappears when I remove a single spec, regardless of which one it is. It even disappears when I add a spec, for example:
When the issue appears, it is consistent. Until I change my tests in some way (add a spec / remove a spec), it consistently appears on separate runs. It doesn’t happen in Chrome, only in PhantomJS.
And it becomes even weirder. Now I found a version of test code that triggers the issue (“bad code”) but doesn’t trigger it if the above spec is added (“good code”). When I apply the abovementioned fix (
currentSpecCallbackDepth = 20instead ofcurrentSpecCallbackDepth = 0) and run bad code, it doesn’t trigger the issue anymore, but now good code triggers it instead.