• Save
Jasmine with JS-Test-Driver
Upcoming SlideShare
Loading in...5

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...



Total Views
Views on SlideShare
Embed Views



0 Embeds 0

No embeds



Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
Post Comment
Edit your comment

    Jasmine with JS-Test-Driver Jasmine with JS-Test-Driver Presentation Transcript

    • 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
    • Options for JS test-runner tools
      Env.js and Rhino.js
      V8 JavaScript Engine
      Jasmine-Maven plug-in
      Jasmine-Ruby plug-in
    • 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
    • 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
    • JsTestDriver
    • 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
    • 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
    • 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
    • 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();
    • 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: "com.google.jstestdriver.coverage.CoverageModule"
    • 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
    • Known issue with JTD
      The rake script fails to close Safari window, if it has the developer console opened !!!
    • Questions … ?