Runs Jasmine's HTML Runner using phantomjs.
It uses phantomjs to execute your Jasmine's HTML spec runner and fetches the results when the test ends, outputting it on the console and on a jUnit XML.
It also uses httpd-mock to create a mock http server that may be needed for the tests to run successfuly. This way HTTP protocol dependents such as Requirejs and Less work properly. The mock server also allows you to implement services through a simple configuration object.
phantomjs v1.9 (should work with v1.8)
A JSON file containing the following structure:
"jsonMocksPath": "./mocks/" // default, optional"outputFile": "./TEST-Jasmine.xml" // default, blank to bypass file output"phantomJsLocation": "/usr/local/bin/phantomjs" // only needed if not available in env path. overridable by command line arg --phantom-js-location"quiet": false // default, if true it won't ouput anything to the console"serverRootPath": "." // default"servicesPrefix": "/webservice/" // default, optional"testHtmlFile": "tests.html" // default, overridable by command line arg -t"timeout": 300000 // default, miliseconds until execution stops if tests didn't end"webServices": // optional"get":"YOUR_WEBSERVICE_URI": "WEBSERVICE_JSON_RESULT_FILE.json""YOUR_WEBSERVICE_URI": "WEBSERVICE_JSON_RESULT_FILE.json""post":"YOUR_WEBSERVICE_URI": "WEBSERVICE_JSON_RESULT_FILE.json""YOUR_WEBSERVICE_URI": "WEBSERVICE_JSON_RESULT_FILE.json"
The web service URI can contain variables, for instance, "client/:id" would be caught in a request to "client/123".
No changes are needed to your Jasmine's HTML spec runner, though if you want to have jUnit output you should include the following in your html head:
<!-- ... --><!-- ... -->
Remember to set your src paths correctly. You may find a copy of jasmine-junit reporter inside the assets folder within this application.
Also you'll need to add the reporter to your jasmine environment:
Usage: jasmine-html-runner.js -c <path> [options]Options:-h, --help output usage information-V, --version output the version number--phantom-js-location [path] Path to the phantomjs binary-c, --config <path> Path to the configuration file relative to jasmine-html-runner-t, --test-html-file [filename] Uri of your Jasmine's html spec runner [tests.html]
Here's a small example:
var JasmineHtmlRunner = require"jasmine-html-runner";var jasmineHtmlRunner =configFile: "jasmine-html-runner.json"processexit;;jasmineHtmlRunnerstart;
The object received in the constructor can contain any variable available inside the config file. The reason the configFile is mandatory is because of httpd-mock limitation for the time being.
To run as a grunt task there's grunt-jasmine-html-runner to do the job for you.
- Create the jUnit XML by crawling the DOM using phantom instead of relying on a reporter.
- Allow e-mail output.
- Fix and improve the demo.
The jUnit XML Reporter was retrieved and changed from larrymyers project jasmine-reporters in order to output the XML content to the console (and then intercepted by phantom).