Your SlideShare is downloading. ×
  • Like
  • Save
Jasmine with JS-Test-Driver
Upcoming SlideShare
Loading in...5

Thanks for flagging this SlideShare!

Oops! An error has occurred.


Now you can save presentations on your phone or tablet

Available for both IPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Jasmine with JS-Test-Driver


Explored various java-script test-runners, which are capable of supporting JS tests on major browsers, of which JS-Test-Driver stands the most promising...

Explored various java-script test-runners, which are capable of supporting JS tests on major browsers, of which JS-Test-Driver stands the most promising...

Published in Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads


Total Views
On SlideShare
From Embeds
Number of Embeds



Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

    No notes for slide


  • 1. Problem Statement / Target
    Ability to run JavaScript tests through commandline (not exactly headlessly)
    Integrate test results with the Bamboo build plan
    Visibility of code-coverage
  • 2. Options for JS test-runner tools
    Env.js and Rhino.js
    V8 JavaScript Engine
    Jasmine-Maven plug-in
    Jasmine-Ruby plug-in
  • 3. Env.js & Rhino.js
    Uses its own JS engine
    Is more closer to Mozilla Firefox
    Still does not even behave as a mirror image of Firefox, on commandline
    Findings: behaves as a different browser in itself
    V8 JavaScript Engine
    Google's open source JavaScript engine, used in chrome
    Is a C++ code-base, needs to be compiled on local machine
    Pretty capable, supports Mozilla and chrome, not sure about Safari
    Findings: Pretty capable, but have not explored much
  • 4. Jasmine-Maven Plug-in
    Uses HTMLUnit for headless browser runner
    HTMLUnit’s only supports Firefox and IE
    Findings – not capable to mock Safari capabilities
    Jasmine-Ruby Plug-in
    Has major issues with the “afterEach” and “toContains” Jasmine capabilities
    Can run with any browser – need to open the SpecRunner.html on the browser of choice !!!
    Findings – Promising, but needs to evolve
  • 5. JsTestDriver
  • 6. Why JsTestDriver
    Can run JS tests through commandline, on the browser(ant version) of choice
    Generates output in JUnit format, making it easier for Bamboo integration
    Well compatible with Jasmine
    Possesses code-coverage capability
    Had certain minor issues, which have a workaround now
  • 7. Workarounds required for JTD
    Not fully compatible with prototype.js – required jar fix
    Jasmine spy issue, was unable to remove the spies – required Jasmine-JsTestDriver Adapter fix
    Never closes the browser tab when test-runner completes – added a minor apple-script fix
  • 8. Testing with JTD
    jsTestDriver configuration
    server: http://localhost:9876
    - "tools/jasmine-test-driver/jasmine-1.0.1.js"
    - "tools/jasmine-test-driver/JasmineAdapter.js"
    - "tools/jasmine-test-driver/prototype-"
    - "dist/qowt-browser-unitTests.js"
    rake test
    java -Xms512m -Xmx1024m
    -jar tools/jasmine-test-driver/JsTestDriver-1.2.2.jar
    --port 9876
    --runnerMode DEBUG
    --browser open
    --tests all
    --testOutput tests/test-reports
  • 9. Creating test-append-area
    QOWT.TEST.UTILS = function() {
    return {
    * creates dummy Test Append Area, and appends it to the document object, for running tests headlessly
    * While executing tests on Sumulat, you get "testAppendArea" div present in the html body itself.
    * But, in case of jsTestDriver, you do not have any such div present, and will have to create it on the fly.
    * @return testAppendArea div
    createTestAppendArea: function() {
    vartestAppendAreaContainer = document.getElementById('testAppendArea');
    if(testAppendAreaContainer === null) {
    testAppendAreaContainer = document.createElement("div");
    testAppendAreaContainer.innerHTML = '<div id="testAppendArea"></div>';
    return document.getElementById('testAppendArea');
    USAGE: (CommonContentMrg-test.js)
    testAppendArea = QOWT.TEST.UTILS.createTestAppendArea();
  • 10. Code-Coverage with JTD
    rake coverage
    Coverage configurations
    server: http://localhost:9876
    - "../jasmine-1.0.1.js"
    - "../JasmineAdapter.js"
    - "../prototype-"
    - "../../../dist/qowt-browser-doc-sheet.js"
    - "../../../dist/qowt-browser-point.js"
    - "../../../dist/qowt-browser-testsOnly.js"
    - name: "coverage"
    jar: "tools/jasmine-test-driver/plugins/coverage-1.2.2.jar"
    module: ""
  • 11. Debugging on JTD
    Start the server - java -Xms512m -Xmx1024m -jar tools/jasmine-test-driver/JsTestDriver-1.2.2.jar --port 9876
    Open the browser with the url- http://localhost:9876/capture
    Run the tests - java -Xms512m -Xmx1024m -jar tools/jasmine-test-driver/JsTestDriver-1.2.2.jar --tests all
    Apply the breakpoint
    Run the tests again
  • 12. Known issue with JTD
    The rake script fails to close Safari window, if it has the developer console opened !!!
  • 13. Questions … ?