JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/chai/3.5.0/chai.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mocha/2.4.5/mocha.min.js"></script>
<script src="https://cdn.rawgit.com/jquery/jquery/2.1.4/dist/jquery.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/mocha/2.4.5/mocha.css">
<div id="mocha"></div>
JavaScript
class Person {
constructor(age) {
if (Object.prototype.toString.call(age) !== '[object Number]') throw 'NOT A NUMBER'
this.age = age;
}
howold() {
console.log(this.age);
}
}
var should = chai.should();
mocha.setup('bdd');
describe('Person', function() {
it('should throw if input is not a number', function() {
(function() {
var p1 = new Person('sadf');
}).should.not.throw;
(function(){
var p2= new Person('sdfa');
}).should.throw;
})
})
mocha.run();