Last active
October 3, 2015 15:58
-
-
Save IanBoyanZhang/744811cd8a8010f86a75 to your computer and use it in GitHub Desktop.
Minimal example of setting up a Chai/Mocha sandbox
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe("Vehicle", function() { | |
describe("constructor", function() { | |
it("should have a default type", function() { | |
var car = new Vehicle(); | |
expect(car.type).to.equal("car"); | |
}); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>SandBox</title> | |
<link href='https://cdn.rawgit.com/mochajs/mocha/2.2.5/mocha.css' rel='stylesheet' media="all"/> | |
</head> | |
<body> | |
<div id="mocha"><p><a href=".">Index</a></p></div> | |
<div id="messages"></div> | |
<div id="fixtures"></div> | |
<script src='https://cdn.rawgit.com/mochajs/mocha/2.2.5/mocha.js'></script> | |
<script src="http://chaijs.com/chai.js"></script> | |
<script> | |
// env setup | |
(function(exports) { | |
"use strict"; | |
exports.expect = chai.expect; | |
})(this); | |
</script> | |
<script src="index.js"></script> | |
<script>mocha.setup('bdd')</script> | |
<script src="first_test.js"></script> | |
<script src="second_test.js"></script> | |
<script>mocha.run();</script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(exports) { | |
"use strict"; | |
function Vehicle(type) { | |
this.type = type || "car"; | |
} | |
Vehicle.prototype = { | |
run: function run(speed) { | |
if (!speed) { | |
throw new Error("No speed provided!"); | |
} | |
return this.type + "is running at" + speed + "mph"; | |
} | |
}; | |
exports.Vehicle = Vehicle; | |
})(this); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// void |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment