Uner
Uner

Reputation: 21

Jasmine testing with Phantom js

I wrote the Jasmine test for the javascript. I am trying to run the Jasmine tests using Phantomjs. I downloaded the Phantomjs from Phantomjs.org and tried running it using phantomjs.exe //path to phantom jasmine http://localhost/myJasmineTestRunner.html. Googling doesn't help me out. Can someone suggest me how to test jasmine tests using phantomjs.

Upvotes: 2

Views: 2591

Answers (1)

Lajos Arpad
Lajos Arpad

Reputation: 76564

Running the Tests

In order to run our jasmine test suite on the command line, all we need is:

  • PhantomJS
    Installing PhantomJS from phantomjs.org is fairly trivial (at least on a mac).
  • A URL to our Jasmine test suite
    We already covered jasmine test suites, so we have a URL to a jasmine test suite.
  • A script that loads our URL and parses the results
    Fortunately, PhantomJS provides a working jasmine runner example – all we have to do is download it and use it.

Once we got these, all we have to do is run the following command: phantomjs It doesn’t take more than a few seconds(!) and we are provided with the test results.

This is it. Now, lets run it with our build tool.

* For the purpose of this article, lets assume PhantomJS is installed on the system, our jasmine runner is located at /path/to/run-jasmine.js and our jasmine test suite is located at http://localhost/js/test/unit/

Source.

Upvotes: 2

Related Questions