You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
Repository navigation
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
Compat issue with jasmine 2.0.0 regarding currentSpec.queue.running #5632
However in Jasmine 2.0.0 currentSpec.queue doesn;t exist nor does any "running" property. How do we determine if a spec is running so we can propose a pull request for NG mocks?
Some background for what the code does (if it's not obvious): the reason for this check is that inject and module helper functions are implemented in different ways depending on whether the spec is running or not.
If a spec is not running we need set up the spec so that when jasmine executes it, the injector will inject the nested spec fn. In this case inject is asynchronous:
it('should do something', inject(function(someService) {
}));
however if you use inject from within a spec, the injection must be synchronous. This is commonly used if you need both the module helper and inject helper in the same spec.
@IgorMinar Their response seems reasonable and something that you could modify angular mocks with. Would the simple hack I did work or their reporter option work?
The related issue was closed with Jasmine, and I agree with them that it should be a change in Angular Mocks (after reading their reasoning). I've modified my angular mocks to use the modified code to make this work again and its going well. I request that this change be made to angular mocks too.
isSpecRunning = function () {
return !!currentSpec;
};
because the window.mocha || window.jasmine check seems to have been done on line 1917.
An alternate option, perhaps for users that don't want to add their own beforeEach/afterEach for spec tracking, is to use the Jasmine reporter interface. Adopted for the angular-mock use case, that would look something like the following:
isSpecRunning = (function() { // assumes this function is still guarded by 'if(window.jasmine || window.mocha) {'
if (window.jasmine) {
var specRunning = false;
window.jasmine.getEnv().addReporter({
specStarted: function() { specRunning = true; },
specDone: function() { specRunning = false; }
});
return function() { return specRunning; };
} else {
return function() { return !!currentSpec; };
}
})();
Activity
johnpapa commentedon Jan 4, 2014
What I did in the meantime to get the tests to run is ...
And then ...
It's a hack so I'd love to hear some better options
IgorMinar commentedon Jan 5, 2014
Some background for what the code does (if it's not obvious): the reason for this check is that
injectandmodulehelper functions are implemented in different ways depending on whether the spec is running or not.If a spec is not running we need set up the spec so that when jasmine executes it, the injector will inject the nested spec fn. In this case inject is asynchronous:
however if you use inject from within a spec, the injection must be synchronous. This is commonly used if you need both the
modulehelper andinjecthelper in the same spec.IgorMinar commentedon Jan 5, 2014
this really is a jasmine issue, so I'm eagerly waiting for some reply to jasmine/jasmine#492
johnpapa commentedon Jan 5, 2014
@IgorMinar Their response seems reasonable and something that you could modify angular mocks with. Would the simple hack I did work or their reporter option work?
johnpapa commentedon Jan 7, 2014
The related issue was closed with Jasmine, and I agree with them that it should be a change in Angular Mocks (after reading their reasoning). I've modified my angular mocks to use the modified code to make this work again and its going well. I request that this change be made to angular mocks too.
because the window.mocha || window.jasmine check seems to have been done on line 1917.
An alternate option, perhaps for users that don't want to add their own beforeEach/afterEach for spec tracking, is to use the Jasmine reporter interface. Adopted for the angular-mock use case, that would look something like the following:
I'll make a pull request.
mbenford commentedon Mar 15, 2014
Shouldn't this issue be closed?
Narretz commentedon Jun 20, 2014
indeed, this was fixed in 95f0bf9 @IgorMinar
alter angular-mock file to fix version comaptibility issue with angul…