This is what worked for me in a setup with jstd and ExtJs 4 (which
introduced a dependency management very similar to commonJS).
I use JsTestDriver's ability to serve JavaScript files to the captured
browser by specifiying them in the 'serve' section of the jstd config
file. I also configure the 'Loader' (the ExtJS 'class' responsible for
resolving dependencies) to use synchronous loading. Default behavior
in ExtJS is to load dependencies asynchronously until the page fires
the 'onReady' ('onLoad') event.
Furthermore, I tell the 'Loader' where to find the resource files
since jstd serves all files under the path '/test'.
The advantage of this setup compared to specifiying dependencies in
the 'load' section is that I don't have to care about the *load
order*, since this is handled by the framework.
A typical jstd config file in my setup looks like this:
load:
- jasmine/jasmine-1.1.0/jasmine.js # Jasmine framework
- jasmine/JasmineAdapter.js # Jasmine jstd adapter
- ext/ext-debug.js # basic ExtJS bootstrap classes
- myapp-test/util/loader.js # configure Ext.Loader
test:
- myapp-test/controller/SomeTests.js
serve:
- myapp/app/*.js
- myapp-test/*.js
# ... (all app directories)
- ext/src/*.js
- ext/src/util/*.js
# ... (all ext directories)
Performance of test execution might or might not improve with this
setup. On the upside, only required dependencies are loaded which
should speed up test execution. However, these dependencies are loaded
synchronously which might actually have a rather significant negative
effect on execution time.
Also, I am not sure how jstd handles files in the serve section (or
files in general). Does the jstd client upload all files to the jstd
server, or are they streamed on demand?
The described setup works for me. However, I wonder whether it might
be possible to write a jstd plugin that allows ExtJs to load files
asynchronously, and delay test execution until all dependencies are
resolved and executed. Haven't looked into this yet!
Sam