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
Which loads the deluge of javascript in our application (which I've omitted a ton of in this example)
# application.js.erb
<%
# 3rd Party Dependencies
%w(
i18n
lodash
jquery3
# etc, etc
).each do |asset|
require_asset asset
end
# Configuration
%w(
config
).each do |asset|
require_asset asset
end
# Modules
%w(
module
mayhem
meltdown
# etc, etc
).each do |asset|
require_asset asset
end
Suppose I have the following code in my Foobar module, which has it's own config
// in config.js(function(){'use strict';window.config=window.config||{};window.config.foobar={delay: 4000};})();// in foobar.jsregisterModule('foobar',(function(){'use strict';return{init: function(){_.delay(function(){$('.baz').remove();},config.foobar.delay);}}})();
This will delete the .baz element after 4000 milliseconds. Here's my test:
(function(){'use strict';describe('foobar',function(){describe('init',function(){it('should eventually remove .baz',function(done){fixture.set('<div class="baz"></div>');foobar.init();_.delay(function(){expect($('.baz').length).to.equal(0);done();},config.foobar.delay);});});});})();
As is, this test would fail, since 4000 is twice as long as the default 2000 timeout. So my test should utilize this approach to change the config, just for this test:
(function(){'use strict';vardelay=config.foobar.delay;before(function(){config.foobar.delay=100;// of any value below 2000});after(function(){config.foobar.delay=delay;});describe('foobar',function(){describe('init',function(){it('should eventually remove .baz',function(done){fixture.set('<div class="baz"></div>');foobar.init();_.delay(function(){expect($('.baz').length).to.equal(0);done();},config.foobar.delay);});});});})();
However, this fails consistently for me. The done method is not being called within 2000 milliseconds.
If I comment out the config.foobar.delay = delay; within the after function, the test will consistently pass.
console.loging any string in the before and after test shows that they seem to be being excuted at the expected times, but from the behavior I'm seeing, it's almost as though the after function is being executed during the test run.
Has anyone seen this or does anyone know what might be causing this issue?
The text was updated successfully, but these errors were encountered:
I've been messing around with this for about a week and feel completely crazy at this point.
In our application we have modules. We also have a configuration object which impacts these modules.
The spec helper loads our manifest
Which loads the deluge of javascript in our application (which I've omitted a ton of in this example)
# application.js.erb <% # 3rd Party Dependencies %w( i18n lodash jquery3 # etc, etc ).each do |asset| require_asset asset end # Configuration %w( config ).each do |asset| require_asset asset end # Modules %w( module mayhem meltdown # etc, etc ).each do |asset| require_asset asset end
Suppose I have the following code in my Foobar module, which has it's own config
This will delete the
.baz
element after4000
milliseconds. Here's my test:As is, this test would fail, since
4000
is twice as long as the default2000
timeout. So my test should utilize this approach to change the config, just for this test:However, this fails consistently for me. The
done
method is not being called within2000
milliseconds.If I comment out the
config.foobar.delay = delay;
within theafter
function, the test will consistently pass.console.log
ing any string in thebefore
andafter
test shows that they seem to be being excuted at the expected times, but from the behavior I'm seeing, it's almost as though the after function is being executed during the test run.Has anyone seen this or does anyone know what might be causing this issue?
The text was updated successfully, but these errors were encountered: