There are a few issues that need to be addressed with the way we load source files:
1.With the typical Jasmine test runner, tests are executed on window.load. Our scripts are fetched for instrumentation on window.load (which is done before Jamsine starts) but it is done asynchronously so before it is finished the test runner begins.
2.Since files are fetched asynchronously, they don't end up respecting the order placed in the HTML file. For example, in backbone koans, if you add data-cover to jquery and to templates.js, you'll notice that template.js (a jquery plugin) is smaller and is therefore loaded before jquery (to which it depends on). This applies only to situations where the test author is not already using requirejs.
Thoughts:
1.There are some simple ways to address this issue, but because we want Blanket to be as seamless as possible (fewest changes to the existing test runner) we have less options.
I think it could work if I override the jasmine.getEnv().execute() function when I attach the jasmine-blanket adapter and basically mock it out. Then we can control exactly when the test starts. This would all be done within the jasmine-blanket adapter, but I'm undecided if this is a good approach. For one it would make the adapter less modular, since we'll need to access the global jasmine object, rather than a local version (as is being done presently).
2.The quick and dirty way to resolve this could be to nest require statements based on order. So, for example, if we have 3 scripts in the HTML page:
<script src="a.js"></script>
<script src="b.js"></script>
<script src="c.js"><script>
Then our blanket code would dynamically generate the following loading approach:
require(["a.js"],function(){
require(["b.js"],function(){
require(["c.js"],function(){
//do callback, probably start test
}
}
}
Any ideas or suggestions would be appreciated. Thanks.