UNPKG

1.09 kBHTMLView Raw
1<html>
2 <head>
3 <title>Test</title>
4 <meta charset="utf-8">
5 <link rel="stylesheet" href="../../node_modules/mocha/mocha.css" />
6 <script src="../../node_modules/mocha/mocha.js"></script>
7 <script src="../../node_modules/chai/chai.js"></script>
8 </head>
9 <body>
10 <div id="mocha"></div>
11 <script>
12 expect = chai.expect;
13
14 describe('Event Tests', function() {
15 it('Fails tests', function() {
16 console.log('from test')
17 expect(1).to.be.ok;
18 });
19 });
20
21 var runner = mocha.run(function() {
22 console.log('Run callback fired');
23 });
24 // because reporters also bind to the 'test end' event when reporting their status,
25 // we need to call 'runner.fail' to mark the test as failed before the runner
26 // gets the test status. Here, we prepend our 'test end' handler to the beginning
27 // of the list.
28 runner.$events['test end'].unshift(function(test) {
29 console.log('from runner')
30 runner.fail(test, new Error('Failed via an event'));
31 });
32 </script>
33 </body>
34</html>