This project demonstrates how you can test AMD modules with Jasmine using JSTestDriver. Unlike other setups like podefr/jasmine-reqjs-jstd these modules can be anonymous modules.
-
Clone the repository
-
cd to the project's root directory
-
Start the JSTestDriver server:
java -jar bin/JsTestDriver-1.3.4.b.jar --port 9876
-
Open
http://localhost:9876/capture
in the browser(s) you want to run the tests inYou can use phantomJS to run the tests with the included runner:
/path/to/phantomjs spec/lib/phantom_runner.js http://localhost:9876/capture
-
Run the test suite:
java -jar bin/JsTestDriver-1.3.4.b.jar --reset --tests all
RequireJS fetches the modules from the test server just like it would in a development environment. For this to work two things have to be done:
-
JSTestDriver needs to be told to serve the modules. It does so for all files that match the pattern under the
serve:
directive injsTestDriver.conf
. -
All file paths need to be prefixed with
/test/
. This is done using thebaseUrl
configuration option inspec/lib/require_config.js
.