I'm using QUnit to test my JavaScript. I'm also using requirejs. I have test code which looks like this:
QUnit.config.autostart = false;
require(['tests/tests'], function () {
QUnit.start(); //Tests loaded, run tests
});
This works great in FF (19.0.2 as it happens) but in both Chrome (27) and IE (10), I'm getting a QUnit error:
"pushFailure() assertion outside test context"
Turns out that I don't need the call to QUnit.start in IE and Chrome. Anybody else seen this or have any suggestions as to why?
If anybody else hits this issue I've found a solution. Empirically both Chrome and IE fire QUnit's load event as soon as QUnit is accessed and load calls start. What I've done is this:
<script type="text/javascript" src="qunit-1.11.0.js"></script>
<script type="text/javascript">
QUnit.config.autostart = false;
</script>
<script type="text/javascript" data-main="main" src="require.js"></script>
So, load QUnit, set the autostart and then load requirejs
This is messier than setting autostart=false in main.js but it has the benefit of working :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With