I'm having some problems with our feature specs. I currently suspect requirejs to be the evildoer. It seems that our specs (Rails with capybara-webkit) start running before all JavaScript files are loaded. Capybara-webkit allows me to evaluate Javascript in Webkit, and I would like to use that to make sure that everything is in place before I start the test run.
Can I somehow query requirejs for the modules it loaded? Are there events I can listen to? Or can I inject a requirejs module at test runtime to set a global state that I can query from my tests (not really my preferred solution)?
I'm not a requirejs expert and haven't implemented much of our JavaScript, but I need to fix it ;)
I found the answer here: You can ask with
require.defined('modules/booking_form/main'), if that module is loaded or not. With a customwait_untilI can delay my test run until everything is in place.