HTML and CSS Reference
In-Depth Information
Port 4224 is the defacto standard JsTestDriver port, but it is arbitrarily picked
and you can run it on any port you want. Once the server is running, the shell
running it must stay open for as long as you need it.
3.4.3.4 Capturing Browsers
Open any browser and point it to http://localhost:4224 (make sure you change the
port number if you used another port when starting the server). The resulting page
will display two links: Capture browser and Capture in strict mode . JsTestDriver runs
tests inside an HTML 4.01 document, and the two links allow us to decide if we
want to run tests with a transitional or strict doctype. Click the appropriate link,
and leave the browser open. Repeat in as many browsers as desired. You can even
try hooking up your phone or browsers on other platforms using virtual instances.
3.4.3.5 Running Tests
Tests can be run from the command line, providing feedback in much the same way
a unit testing framework for any server-side language would. As tests are run, a dot
will appear for every passing test, an F for a failing test, and an E for a test with
errors. An error is any test error that is not a failing assertion, i.e., an unexpected
exception. To run the tests, we need a small configuration file that tells JsTestDriver
which source and test files to load (and in what order), and which server to run tests
against. The configuration file, jsTestDriver.conf by default, uses YAML syntax,
and at its simplest, it loads every source file and every test file, and runs tests at
http://localhost:4224, as seen in Listing 3.6.
Listing 3.6 A barebone jsTestDriver.conf file
server: http://localhost:4224
load:
- src/*.js
- test/*.js
Load paths are relative to the location of the configuration file. When it's re-
quired to load certain files before others, we can specify them first and still use the
*.js notation, JsTestDriver will only load each file once, even when it is referenced
more than once. Listing 3.7 shows an example where src/mylib.js always need
to load first.
 
Search WWH ::




Custom Search