Skip to content

Instantly share code, notes, and snippets.

@NelsonMinar
Last active February 10, 2018 12:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save NelsonMinar/afc0574a9755f627f91d6bd45fa44767 to your computer and use it in GitHub Desktop.
Save NelsonMinar/afc0574a9755f627f91d6bd45fa44767 to your computer and use it in GitHub Desktop.
Demo of using Mocha + Chai in a browser without Node
<html>
<head>
<meta charset="utf-8">
<title>Mocha Tests</title>
<link href="https://cdnjs.cloudflare.com/ajax/libs/mocha/5.0.0/mocha.css" rel="stylesheet" />
</head>
<body>
<div id="mocha"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mocha/5.0.0/mocha.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/chai/4.1.2/chai.js"></script>
<script>mocha.setup('bdd')</script>
<script>
var assert = chai.assert;
describe('Browser demo', function() {
it('should work', function() {
assert.equal(1, 1);
});
it('should fail', function() {
assert.equal(3, 4);
});
});
</script>
<script>
mocha.checkLeaks();
mocha.run();
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment