First Mocha Test
simple tests with Mocha and Chai
HTML
<link rel="stylesheet" href="https://s3.amazonaws.com/kiddsoftware-jsfiddle/mocha-1.9.0.css">
<script src="https://s3.amazonaws.com/kiddsoftware-jsfiddle/mocha-1.9.0.js"></script>
<script src=" https://s3.amazonaws.com/kiddsoftware-jsfiddle/chai-1.5.0.js"></script>
<script src="https://s3.amazonaws.com/kiddsoftware-jsfiddle/chai-jquery.js"></script>
<!-- Mocha test output goes here. -->
<div><p>First Line</p></div>
<div><p>Second Line</p></div>
<div id="mocha"></div>
CSS
p {
padding: 0;
margin: 0;
}
div:nth-child(1) > p {
color: green;
}
div::nth-child(2) > p {
color: blue;
}
JavaScript
// Configure Mocha, telling both it and chai to use BDD-style tests.
mocha.setup("bdd");
chai.should();
//for reference
var asdf = 'tests.'; //outside vars/fns ARE in the scope of Describe() and It()
var j = function(){ return "Hello" };
describe('Simple ' + asdf, function(){
it('true = false?', function(){
var j = true;
var i = false;
i.should.equal(j);
});
it('true = true?', function(){
var j = true;
var i = true;
i.should.equal(j);
});
it('i[3] = j?', function(){
var i = [1,2,3, "Hello"];
i[3].should.equal(j());
});
});
// Run all our test suites. Only necessary in the browser.
mocha.run();