Wow, what a mess. This is a script.
- JS application with a managed database.
Require JS for AMD functionality, initialized as follows:
<script data-main="js/main" src="js/require.js" type="text/javascript"></script>
then inside main.js the following configuration code:
require.config( { paths: { ... : ... } });
Each Backbone View / Model / Router is a module "define (...)" and "require (" theOneRouter ", ...)" is called once in main.js.
r.js is used as an optimizer with Uglify / Closure. One "compiled" main.js is created in a subdirectory. / release, which I choose dynamically within my .net.
It took a while to get Backbone + Require.JS to work, but now it works great!
Then, patting Jasmine on top of this, he did a bit of work too, but he worked just fine. I had to download require.js from my SpecRunner.html, define each test module as AMD using require define (...) call, and I instantiate and run Jasmine once from the call to require (...) call once in SpecRunner.html:
require( [ //"test/specs/testSpec1", "test/specs/views" ], function () { jasmine.getEnv().updateInterval = 1000; var reporter = new jasmine.TrivialReporter(); jasmine.getEnv().addReporter(reporter); .... .... });
This works fine too. Tests load and run without problems. The requirement takes care of everything.
Now I would like for my runner to work as JSTestDriver. I chose JSTD for simplicity, the ability to test on remote browsers, support for code coverage, but I'm still open to other suggestions.
JSTestDriver itself works just fine, the only problem I am facing is sharing JSTD + Jasmine + ReuireJS. The biggest problem is that if I tell JSTD in the configuration file about the Jasmine / Require test module to load it, I get the following error:
http://requirejs.org/docs/errors.html#mismatch
If I use r.js to select all of my code into a single main.js file, the combination works, including Coverage, but the coverage is collected in one giant file and is difficult to parse. Not to mention the fact that it takes a lot of time to create a js file of 50k lines of code and to run it through JSTD.
I tried to create a js file that looks like a file that loads all of my Jasmine test modules and code modules, but I keep returning to the above โinconsistencyโ error, And if I don't tell JSTD about each module separately (by loading html / js -adaptation that makes the actual download), they will not get the tools to cover the code.
Has anyone got this particular combination to work? Maybe I ask too much ...
Bernardo
source share