block by NelsonMinar afc0574a9755f627f91d6bd45fa44767

Demo of using Mocha + Chai in a browser without Node

Full Screen

index.html

<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>