简体   繁体   中英

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.

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM