npm install jasmine-phantom-node
|10||downloads in the last day|
|83||downloads in the last week|
|218||downloads in the last month|
|Version||0.2.0 last updated a year ago|
|Dependencies||express, colors, node-phantom, coffee-script|
What does this do exactly?
I wrote this to execute jasmine specs without a browser using phantom-js + node
Why did you write another js test runner?
- phantom-js works if you don't mind opening a browser or using js-test-driver
- jasmine-phantom-node is the best of both => no browser, yet every spec is executed like a browser would
How do I get started then?
First you need to install PhantomJS on your machine
If you are using OSX you can use brew
brew install phantomjs
If you are on Ubuntu you can use apt-get
apt-get install phantomjs
Next you need to create a file named "phantom-runner.html" in the root of your project
It's required to include the jasmine.js and jasmine-html.js files here along with a modern jQuery
Here is a very simple example of what this html file might look like
The location of static/* should be the root asset directory of your webapp
For example, say I have a web app with this dir structure
--project --webapp --static --script --tests --foo.spec.js
When you run this you need to pass in a directory or list of directories
The test runner will only add files with the extension .spec.js to the dom
With the example above you would tell the test runner to find and exec each spec under the tests directory like so
node jasmine-phantom-node webapp/static/script/tests
The test runner will load each test directory recursively so avoid the following (results in duplicate specs being run)
node jasmine-phantom-node webapp/static/script/tests/views webapp/static/script/tests/models
You will run the command above from the root of your project
At this time it's required to install this npm module locally -not globally
What about these optional command line flags?
--coffee will tell the test runner to compile any .coffee files found in the directory --noColor simply removes the red/green color output (useful on your ci server) --junitreport at a future date this will generate a junit xml file with your test results --debug will tell the express web server to keep running so you can open the browser and debug your test code
So what is missing from this test project today?
- Include the full jasmine stacktrace in the test results
- Include support for the junit xml reporting built into jasmine already
- A pull request is needed for the npm project "phantomjs-node" to remove a few express warnings that shows up
- Multi directory support (currently you can pass in more than 1 directory but it doesn't filter unique specs at this time)