-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Using delay in setup() depends on object property ordering #1799
Comments
@hollomancer I think #1800 should fix this issue and all comments were addressed, but the |
I am a bot that watches issues for inactivity. |
PR needs review again |
Any updates on this? This is still an issue for karma-mocha and it should be an easy fix. |
mocha.setup = function(opts) {
if (typeof opts === 'string') {
opts = {ui: opts};
}
Object.keys(opts).sort().forEach(function(opt) {
if (opts.hasOwnProperty(opt)) {
this[opt](opts[opt]);
}
}
return this;
};
|
easy fix, more difficult to test without refactors. and yes, we need a real test. #1800 added a test, but not an automated one. |
Sounds like there are 2 bugs right now in the browser usage.
Perhaps something like below to fix both issues? if ('delay' in opts && opts['delay'] === true) {
this.delay();
}
var self = this;
Object.keys(opts)
.filter(function(opt) {
return opt !== 'delay';
})
.forEach(function(opt) {
if (Object.prototype.hasOwnProperty.call(opts, opt)) {
self[opt](opts[opt]);
}
}); @boneskull What level of testing would we need with this do u think? AFAIK html reporter tests are not ready, could introduce a unit-level somewhere. |
This should now be fixed in the latest PR. |
When trying to set
{delay: true}
in amocha.setup()
call, it only works if thedelay
property is set before theui
property.Here's some reproduction steps for Chrome.
In the case where it doesn't work, the global
run()
method is undefined.The issue is that mocha.setup() just iterates over the properties and calls their corresponding methods
And in the
ui
method, thepre-require
event is emitted, and it's in those event handlers that the global "run" method is supposed to be registered:However, if the
ui
method is called before thedelay
method, thenmocha.options.delay
will not be set and the globalrun
method will not be defined.The text was updated successfully, but these errors were encountered: