jasmine test running on jsFiddle

jsFiddle template to run a jasmine test inside jsFiddle. Adds jasmine external resources, and initializes jasmine's HtmlReporter on window load. For more infor check this article: http://opensas.wordpress.com/2013/06/23/sharing-you-javascript-ninja-secrets-run-your-jasmine-tests-on-jsfiddle/

by Divyanth Jayaraj

HTML

<link rel="stylesheet" href="//cdn.jsdelivr.net/jasmine/1.3.1/jasmine.css">
<script src="//cdn.jsdelivr.net/jasmine/1.3.1/jasmine.js"></script>
<script src="//cdn.jsdelivr.net/jasmine/1.3.1/jasmine-html.js"></script>
<title>Jasmine Spec Runner</title>

<table id="myTable">
<tr><td>Foo1</td><td>Foo2</td></tr>
<tr><td>bar1</td><td>Bar2</td></tr>
</table>
<div id="result">

</div>

JavaScript

$('#greet').on("click", function() {
	$('#greet').next('div').text('hello');
});


//console.log($('div').text());
// specs code
var executeTests = function(){
describe("HTML/Javascript tutorial for noobs", function() {
	
  
  it("After clicking button, div below it should have text 'hello'", function() {
  	$('#greet').trigger('click');
    var target = $('#greet').next('div').text();
    expect(target).toMatch(/hello/);
  });
  
  it('Should have a table with id "myTable" , 2 rows and 2 columns', function(){
  	expect($('table').attr('id')).toMatch(/myTable/);
    expect($('table tr').length).toEqual(2);
    expect($('table td').length).toEqual(4);
  });
  
  it("Should have a textbox with placeholder 'yoyoyo'", function() {
  	var target = $('input');
    expect($(target).attr('placeholder')).toMatch('yoyoyo');
  });

});




var NOT_IMPLEMENTED = undefined;

// load jasmine htmlReporter
/*(function() {
  var env = jasmine.getEnv();
  //env.addReporter(new jasmine.HtmlReporter());
  env.execute();
}());*/
var env = jasmine.getEnv();
  //env.addReporter(new jasmine.HtmlReporter());
env.execute();

var specResults = env.currentSpec.suite.specs_;
console.log(specResults);
var resultHtml = '';

var specsArray = [];
for(var i=0;i<specResults.length;i++) {
	var specObj = {};
  specObj.description = specResults[i].description;
  specObj.passed = (specResults[i].results_.failedCount == 0);
  specsArray.push(specObj);
}
 
console.log("Specs array", specsArray);

$('#result').append(resultHtml);
}();