Last active
June 12, 2022 11:00
-
-
Save remarkablemark/04cb6bc9332bef3daace857520ad3608 to your computer and use it in GitHub Desktop.
Example of mocha in the browser.
This file contains hidden or 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> | |
<!-- styling for the test results --> | |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/mocha/3.1.0/mocha.min.css" /> | |
</head> | |
<body> | |
<!-- container that will display test results --> | |
<div id="mocha"></div> | |
<!-- mocha (test runner) --> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/mocha/3.1.0/mocha.min.js"></script> | |
<!-- chai (assertion library) --> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/chai/3.5.0/chai.min.js"></script> | |
<script> | |
// setup test helpers | |
mocha.setup('bdd'); | |
// your tests here | |
describe('test suite', function() { | |
it('should work', function() { | |
chai.assert(true); | |
}); | |
}); | |
// run tests | |
mocha.run(); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can also install mocha and chai locally:
You'll also need to update the script source.