Monthly Archives: February 2013 @ The Manx – 2013.2.21

Photos of Taipei python user group monthly meetup at The Manx on 2013.2.21.
The Manx Entertainment Group

_DSC1899 _DSC1911 Read the rest of this entry »

Leave a comment

Posted by on February 25, 2013 in Uncategorized


Tags: ,

BDD and test coverage measuring with Jasmine and JSCover tutorial


[Jasmine]( is a popular BDD framework for Javascript programs. It’s a standalone framework and there are HTML reporter, console reporter, … and more to choose from. To test Javascript in CocoonJS platform we can use the console reporter.

To try Jasmine:

1. Download [Jasmine](

2. Unzip the downloaded Jasmine standalone package. You can either open the SpecRunner.html with browsers or place the files in a web server and visit the url.

The default demo uses HTML reporter. Here is an example html of using the console reporter:
Download additional reporters: [](

  <title>Jasmine Spec Runner</title>

  <link rel="shortcut icon" type="image/png" href="test/lib/jasmine-1.3.1/jasmine_favicon.png">
  <link rel="stylesheet" type="text/css" href="test/lib/jasmine-1.3.1/jasmine.css">
  <script type="text/javascript" src="test/lib/jasmine-1.3.1/jasmine.js"></script>
  <script type="text/javascript" src="test/lib/jasmine-1.3.1/jasmine-html.js"></script>
  <script type="text/javascript" src="test/lib/jasmine.console_reporter.js"></script>

  <!-- include source files here... -->

  <!-- include spec files here... -->

  <script type="text/javascript">
    (function() {

      // HTML Reporter
      // var jasmineEnv = jasmine.getEnv();
      // jasmineEnv.updateInterval = 1000;

      // var htmlReporter = new jasmine.HtmlReporter();

      // jasmineEnv.addReporter(htmlReporter);

      // jasmineEnv.specFilter = function(spec) {
      //   return htmlReporter.specFilter(spec);
      // };

      // var currentWindowOnload = window.onload;

      // window.onload = function() {
      //   if (currentWindowOnload) {
      //     currentWindowOnload();
      //   }
      //   execJasmine();
      // };

      // function execJasmine() {
      //   jasmineEnv.execute();
      // }

      // Console Reporter
      jasmine.getEnv().addReporter(new jasmine.ConsoleReporter());




We can also use both reporters in the same spec runner page.


To measure the test coverage for our Javascript program we can use JSCover. Here’s a step by step guide to use JSCover in server mode:

1. Download [JSCover](

2. Unzip the downloaded file and run

Mac: In terminal, type “sh”

Windows: In cmd, type “”

3. Visit [demo page](http://localhost:8080/jscoverage.html?/index.html).

4. In the Browser tab of the page, type in the test code running url in the URL box and then click “Open in frame”. Note that the domain and port of the test url has to be the same as the JSCover page.

The default script in is

    java -jar target/dist/JSCover-all.jar -ws --branch --document-root=doc/example --report-dir=target

We can use –no-instrument to specify the url that not to be instrumented. For example:

    java -jar target/dist/JSCover-all.jar -ws --branch --document-root=doc/example --report-dir=test/report --no-instrument=test

You can find more detailed options at [JSCover manual](


1. [JSCover Guide](

2. [JSCover manual](

Leave a comment

Posted by on February 19, 2013 in Javascript


Tags: , , ,