konacha 1.2.4 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -407,7 +407,7 @@ module.exports = Context;
407
407
  function Context(){}
408
408
 
409
409
  /**
410
- * Set the context `Runnable` to `runnable`.
410
+ * Set or get the context `Runnable` to `runnable`.
411
411
  *
412
412
  * @param {Runnable} runnable
413
413
  * @return {Context}
@@ -415,7 +415,8 @@ function Context(){}
415
415
  */
416
416
 
417
417
  Context.prototype.runnable = function(runnable){
418
- this._runnable = runnable;
418
+ if (0 == arguments.length) return this._runnable;
419
+ this.test = this._runnable = runnable;
419
420
  return this;
420
421
  };
421
422
 
@@ -428,7 +429,7 @@ Context.prototype.runnable = function(runnable){
428
429
  */
429
430
 
430
431
  Context.prototype.timeout = function(ms){
431
- this._runnable.timeout(ms);
432
+ this.runnable().timeout(ms);
432
433
  return this;
433
434
  };
434
435
 
@@ -441,9 +442,9 @@ Context.prototype.timeout = function(ms){
441
442
 
442
443
  Context.prototype.inspect = function(){
443
444
  return JSON.stringify(this, function(key, val){
444
- return '_runnable' == key
445
- ? undefined
446
- : val;
445
+ if ('_runnable' == key) return;
446
+ if ('test' == key) return;
447
+ return val;
447
448
  }, 2);
448
449
  };
449
450
 
@@ -484,6 +485,25 @@ Hook.prototype = new Runnable;
484
485
  Hook.prototype.constructor = Hook;
485
486
 
486
487
 
488
+ /**
489
+ * Get or set the test `err`.
490
+ *
491
+ * @param {Error} err
492
+ * @return {Error}
493
+ * @api public
494
+ */
495
+
496
+ Hook.prototype.error = function(err){
497
+ if (0 == arguments.length) {
498
+ var err = this._error;
499
+ this._error = null;
500
+ return err;
501
+ }
502
+
503
+ this._error = err;
504
+ };
505
+
506
+
487
507
  }); // module: hook.js
488
508
 
489
509
  require.register("interfaces/bdd.js", function(module, exports, require){
@@ -573,7 +593,7 @@ module.exports = function(suite){
573
593
  * acting as a thunk.
574
594
  */
575
595
 
576
- context.it = function(title, fn){
596
+ context.it = context.specify = function(title, fn){
577
597
  suites[0].addTest(new Test(title, fn));
578
598
  };
579
599
  });
@@ -847,7 +867,6 @@ module.exports = function(suite){
847
867
  }); // module: interfaces/tdd.js
848
868
 
849
869
  require.register("mocha.js", function(module, exports, require){
850
-
851
870
  /*!
852
871
  * mocha
853
872
  * Copyright(c) 2011 TJ Holowaychuk <tj@vision-media.ca>
@@ -870,7 +889,7 @@ exports = module.exports = Mocha;
870
889
  * Library version.
871
890
  */
872
891
 
873
- exports.version = '1.1.0';
892
+ exports.version = '1.2.1';
874
893
 
875
894
  /**
876
895
  * Expose internals.
@@ -995,11 +1014,12 @@ Mocha.prototype.growl = function(runner, reporter) {
995
1014
  var stats = reporter.stats;
996
1015
  if (stats.failures) {
997
1016
  var msg = stats.failures + ' of ' + runner.total + ' tests failed';
998
- notify(msg, { title: 'Failed', image: image('fail') });
1017
+ notify(msg, { name: 'mocha', title: 'Failed', image: image('error') });
999
1018
  } else {
1000
1019
  notify(stats.passes + ' tests passed in ' + stats.duration + 'ms', {
1001
- title: 'Passed'
1002
- , image: image('pass')
1020
+ name: 'mocha'
1021
+ , title: 'Passed'
1022
+ , image: image('ok')
1003
1023
  });
1004
1024
  }
1005
1025
  });
@@ -1040,6 +1060,7 @@ Mocha.prototype.run = function(fn){
1040
1060
  if (options.growl) this.growl(runner, reporter);
1041
1061
  return runner.run(fn);
1042
1062
  };
1063
+
1043
1064
  }); // module: mocha.js
1044
1065
 
1045
1066
  require.register("reporters/base.js", function(module, exports, require){
@@ -1454,28 +1475,11 @@ function Doc(runner) {
1454
1475
 
1455
1476
  runner.on('pass', function(test){
1456
1477
  console.log('%s <dt>%s</dt>', indent(), test.title);
1457
- var code = utils.escape(clean(test.fn.toString()));
1478
+ var code = utils.escape(utils.clean(test.fn.toString()));
1458
1479
  console.log('%s <dd><pre><code>%s</code></pre></dd>', indent(), code);
1459
1480
  });
1460
1481
  }
1461
1482
 
1462
- /**
1463
- * Strip the function definition from `str`,
1464
- * and re-indent for pre whitespace.
1465
- */
1466
-
1467
- function clean(str) {
1468
- str = str
1469
- .replace(/^function *\(.*\) *{/, '')
1470
- .replace(/\s+\}$/, '');
1471
-
1472
- var spaces = str.match(/^\n?( *)/)[1].length
1473
- , re = new RegExp('^ {' + spaces + '}', 'gm');
1474
-
1475
- str = str.replace(re, '');
1476
-
1477
- return str;
1478
- }
1479
1483
  }); // module: reporters/doc.js
1480
1484
 
1481
1485
  require.register("reporters/dot.js", function(module, exports, require){
@@ -1584,6 +1588,13 @@ function HTMLCov(runner) {
1584
1588
  });
1585
1589
  }
1586
1590
 
1591
+ /**
1592
+ * Return coverage class for `n`.
1593
+ *
1594
+ * @return {String}
1595
+ * @api private
1596
+ */
1597
+
1587
1598
  function coverageClass(n) {
1588
1599
  if (n >= 75) return 'high';
1589
1600
  if (n >= 50) return 'medium';
@@ -1671,7 +1682,7 @@ function HTML(runner) {
1671
1682
  if (suite.root) return;
1672
1683
 
1673
1684
  // suite
1674
- var url = location.origin + location.pathname + '?grep=^' + utils.escapeRegexp(suite.fullTitle());
1685
+ var url = location.protocol + '//' + location.host + location.pathname + '?grep=^' + utils.escapeRegexp(suite.fullTitle());
1675
1686
  var el = fragment('<li class="suite"><h1><a href="%s">%s</a></h1></li>', url, suite.title);
1676
1687
 
1677
1688
  // container
@@ -1738,7 +1749,7 @@ function HTML(runner) {
1738
1749
  // code
1739
1750
  // TODO: defer
1740
1751
  if (!test.pending) {
1741
- var pre = fragment('<pre><code>%e</code></pre>', clean(test.fn.toString()));
1752
+ var pre = fragment('<pre><code>%e</code></pre>', utils.clean(test.fn.toString()));
1742
1753
  el.appendChild(pre);
1743
1754
  pre.style.display = 'none';
1744
1755
  }
@@ -1797,27 +1808,6 @@ function on(el, event, fn) {
1797
1808
  el.attachEvent('on' + event, fn);
1798
1809
  }
1799
1810
  }
1800
-
1801
- /**
1802
- * Strip the function definition from `str`,
1803
- * and re-indent for pre whitespace.
1804
- */
1805
-
1806
- function clean(str) {
1807
- str = str
1808
- .replace(/^function *\(.*\) *{/, '')
1809
- .replace(/\s+\}$/, '');
1810
-
1811
- var spaces = str.match(/^\n?( *)/)[1].length
1812
- , re = new RegExp('^ {' + spaces + '}', 'gm');
1813
-
1814
- str = str
1815
- .replace(re, '')
1816
- .replace(/^\s+/, '');
1817
-
1818
- return str;
1819
- }
1820
-
1821
1811
  }); // module: reporters/html.js
1822
1812
 
1823
1813
  require.register("reporters/index.js", function(module, exports, require){
@@ -2304,7 +2294,6 @@ List.prototype.constructor = List;
2304
2294
  }); // module: reporters/list.js
2305
2295
 
2306
2296
  require.register("reporters/markdown.js", function(module, exports, require){
2307
-
2308
2297
  /**
2309
2298
  * Module dependencies.
2310
2299
  */
@@ -2384,9 +2373,9 @@ function Markdown(runner) {
2384
2373
  });
2385
2374
 
2386
2375
  runner.on('pass', function(test){
2387
- var code = clean(test.fn.toString());
2376
+ var code = utils.clean(test.fn.toString());
2388
2377
  buf += test.title + '.\n';
2389
- buf += '\n```js';
2378
+ buf += '\n```js\n';
2390
2379
  buf += code + '\n';
2391
2380
  buf += '```\n\n';
2392
2381
  });
@@ -2397,24 +2386,6 @@ function Markdown(runner) {
2397
2386
  process.stdout.write(buf);
2398
2387
  });
2399
2388
  }
2400
-
2401
- /**
2402
- * Strip the function definition from `str`,
2403
- * and re-indent for pre whitespace.
2404
- */
2405
-
2406
- function clean(str) {
2407
- str = str
2408
- .replace(/^function *\(.*\) *{/, '')
2409
- .replace(/\s+\}$/, '');
2410
-
2411
- var spaces = str.match(/^\n?( *)/)[1].length
2412
- , re = new RegExp('^ {' + spaces + '}', 'gm');
2413
-
2414
- str = str.replace(re, '');
2415
-
2416
- return str;
2417
- }
2418
2389
  }); // module: reporters/markdown.js
2419
2390
 
2420
2391
  require.register("reporters/min.js", function(module, exports, require){
@@ -2459,6 +2430,271 @@ Min.prototype.constructor = Min;
2459
2430
 
2460
2431
  }); // module: reporters/min.js
2461
2432
 
2433
+ require.register("reporters/nyan.js", function(module, exports, require){
2434
+
2435
+ /**
2436
+ * Module dependencies.
2437
+ */
2438
+
2439
+ var Base = require('./base')
2440
+ , color = Base.color;
2441
+
2442
+ /**
2443
+ * Expose `Dot`.
2444
+ */
2445
+
2446
+ exports = module.exports = NyanCat;
2447
+
2448
+ /**
2449
+ * Initialize a new `Dot` matrix test reporter.
2450
+ *
2451
+ * @param {Runner} runner
2452
+ * @api public
2453
+ */
2454
+
2455
+ function NyanCat(runner) {
2456
+ Base.call(this, runner);
2457
+
2458
+ var self = this
2459
+ , stats = this.stats
2460
+ , width = Base.window.width * .75 | 0
2461
+ , rainbowColors = this.rainbowColors = self.generateColors()
2462
+ , colorIndex = this.colorIndex = 0
2463
+ , numerOfLines = this.numberOfLines = 4
2464
+ , trajectories = this.trajectories = [[], [], [], []]
2465
+ , nyanCatWidth = this.nyanCatWidth = 11
2466
+ , trajectoryWidthMax = this.trajectoryWidthMax = (width - nyanCatWidth)
2467
+ , scoreboardWidth = this.scoreboardWidth = 5
2468
+ , tick = this.tick = 0
2469
+ , n = 0;
2470
+
2471
+ runner.on('start', function(){
2472
+ Base.cursor.hide();
2473
+ self.draw('start');
2474
+ });
2475
+
2476
+ runner.on('pending', function(test){
2477
+ self.draw('pending');
2478
+ });
2479
+
2480
+ runner.on('pass', function(test){
2481
+ self.draw('pass');
2482
+ });
2483
+
2484
+ runner.on('fail', function(test, err){
2485
+ self.draw('fail');
2486
+ });
2487
+
2488
+ runner.on('end', function(){
2489
+ Base.cursor.show();
2490
+ for (var i = 0; i < self.numberOfLines; i++) write('\n');
2491
+ self.epilogue();
2492
+ });
2493
+ }
2494
+
2495
+ /**
2496
+ * Draw the nyan cat with runner `status`.
2497
+ *
2498
+ * @param {String} status
2499
+ * @api private
2500
+ */
2501
+
2502
+ NyanCat.prototype.draw = function(status){
2503
+ this.appendRainbow();
2504
+ this.drawScoreboard();
2505
+ this.drawRainbow();
2506
+ this.drawNyanCat(status);
2507
+ this.tick = !this.tick;
2508
+ };
2509
+
2510
+ /**
2511
+ * Draw the "scoreboard" showing the number
2512
+ * of passes, failures and pending tests.
2513
+ *
2514
+ * @api private
2515
+ */
2516
+
2517
+ NyanCat.prototype.drawScoreboard = function(){
2518
+ var stats = this.stats;
2519
+ var colors = Base.colors;
2520
+
2521
+ function draw(color, n) {
2522
+ write(' ');
2523
+ write('\033[' + color + 'm' + n + '\033[0m');
2524
+ write('\n');
2525
+ }
2526
+
2527
+ draw(colors.green, stats.passes);
2528
+ draw(colors.fail, stats.failures);
2529
+ draw(colors.pending, stats.pending);
2530
+ write('\n');
2531
+
2532
+ this.cursorUp(this.numberOfLines);
2533
+ };
2534
+
2535
+ /**
2536
+ * Append the rainbow.
2537
+ *
2538
+ * @api private
2539
+ */
2540
+
2541
+ NyanCat.prototype.appendRainbow = function(){
2542
+ var segment = this.tick ? '_' : '-';
2543
+ var rainbowified = this.rainbowify(segment);
2544
+
2545
+ for (var index = 0; index < this.numberOfLines; index++) {
2546
+ var trajectory = this.trajectories[index];
2547
+ if (trajectory.length >= this.trajectoryWidthMax) trajectory.shift();
2548
+ trajectory.push(rainbowified);
2549
+ }
2550
+ };
2551
+
2552
+ /**
2553
+ * Draw the rainbow.
2554
+ *
2555
+ * @api private
2556
+ */
2557
+
2558
+ NyanCat.prototype.drawRainbow = function(){
2559
+ var self = this;
2560
+
2561
+ this.trajectories.forEach(function(line, index) {
2562
+ write('\033[' + self.scoreboardWidth + 'C');
2563
+ write(line.join(''));
2564
+ write('\n');
2565
+ });
2566
+
2567
+ this.cursorUp(this.numberOfLines);
2568
+ };
2569
+
2570
+ /**
2571
+ * Draw the nyan cat with `status`.
2572
+ *
2573
+ * @param {String} status
2574
+ * @api private
2575
+ */
2576
+
2577
+ NyanCat.prototype.drawNyanCat = function(status) {
2578
+ var self = this;
2579
+ var startWidth = this.scoreboardWidth + this.trajectories[0].length;
2580
+
2581
+ [0, 1, 2, 3].forEach(function(index) {
2582
+ write('\033[' + startWidth + 'C');
2583
+
2584
+ switch (index) {
2585
+ case 0:
2586
+ write('_,------,');
2587
+ write('\n');
2588
+ break;
2589
+ case 1:
2590
+ var padding = self.tick ? ' ' : ' ';
2591
+ write('_|' + padding + '/\\_/\\ ');
2592
+ write('\n');
2593
+ break;
2594
+ case 2:
2595
+ var padding = self.tick ? '_' : '__';
2596
+ var tail = self.tick ? '~' : '^';
2597
+ var face;
2598
+ switch (status) {
2599
+ case 'pass':
2600
+ face = '( ^ .^)';
2601
+ break;
2602
+ case 'fail':
2603
+ face = '( o .o)';
2604
+ break;
2605
+ default:
2606
+ face = '( - .-)';
2607
+ }
2608
+ write(tail + '|' + padding + face + ' ');
2609
+ write('\n');
2610
+ break;
2611
+ case 3:
2612
+ var padding = self.tick ? ' ' : ' ';
2613
+ write(padding + '"" "" ');
2614
+ write('\n');
2615
+ break;
2616
+ }
2617
+ });
2618
+
2619
+ this.cursorUp(this.numberOfLines);
2620
+ };
2621
+
2622
+ /**
2623
+ * Move cursor up `n`.
2624
+ *
2625
+ * @param {Number} n
2626
+ * @api private
2627
+ */
2628
+
2629
+ NyanCat.prototype.cursorUp = function(n) {
2630
+ write('\033[' + n + 'A');
2631
+ };
2632
+
2633
+ /**
2634
+ * Move cursor down `n`.
2635
+ *
2636
+ * @param {Number} n
2637
+ * @api private
2638
+ */
2639
+
2640
+ NyanCat.prototype.cursorDown = function(n) {
2641
+ write('\033[' + n + 'B');
2642
+ };
2643
+
2644
+ /**
2645
+ * Generate rainbow colors.
2646
+ *
2647
+ * @return {Array}
2648
+ * @api private
2649
+ */
2650
+
2651
+ NyanCat.prototype.generateColors = function(){
2652
+ var colors = [];
2653
+
2654
+ for (var i = 0; i < (6 * 7); i++) {
2655
+ var pi3 = Math.floor(Math.PI / 3);
2656
+ var n = (i * (1.0 / 6));
2657
+ var r = Math.floor(3 * Math.sin(n) + 3);
2658
+ var g = Math.floor(3 * Math.sin(n + 2 * pi3) + 3);
2659
+ var b = Math.floor(3 * Math.sin(n + 4 * pi3) + 3);
2660
+ colors.push(36 * r + 6 * g + b + 16);
2661
+ }
2662
+
2663
+ return colors;
2664
+ };
2665
+
2666
+ /**
2667
+ * Apply rainbow to the given `str`.
2668
+ *
2669
+ * @param {String} str
2670
+ * @return {String}
2671
+ * @api private
2672
+ */
2673
+
2674
+ NyanCat.prototype.rainbowify = function(str){
2675
+ var color = this.rainbowColors[this.colorIndex % this.rainbowColors.length];
2676
+ this.colorIndex += 1;
2677
+ return '\033[38;5;' + color + 'm' + str + '\033[0m';
2678
+ };
2679
+
2680
+ /**
2681
+ * Stdout helper.
2682
+ */
2683
+
2684
+ function write(string) {
2685
+ process.stdout.write(string);
2686
+ }
2687
+
2688
+ /**
2689
+ * Inherit from `Base.prototype`.
2690
+ */
2691
+
2692
+ NyanCat.prototype = new Base;
2693
+ NyanCat.prototype.constructor = NyanCat;
2694
+
2695
+
2696
+ }); // module: reporters/nyan.js
2697
+
2462
2698
  require.register("reporters/progress.js", function(module, exports, require){
2463
2699
 
2464
2700
  /**
@@ -2985,6 +3221,22 @@ Runnable.prototype.clearTimeout = function(){
2985
3221
  clearTimeout(this.timer);
2986
3222
  };
2987
3223
 
3224
+ /**
3225
+ * Inspect the runnable void of private properties.
3226
+ *
3227
+ * @return {String}
3228
+ * @api private
3229
+ */
3230
+
3231
+ Runnable.prototype.inspect = function(){
3232
+ return JSON.stringify(this, function(key, val){
3233
+ if ('_' == key[0]) return;
3234
+ if ('parent' == key) return '#<Suite>';
3235
+ if ('ctx' == key) return '#<Context>';
3236
+ return val;
3237
+ }, 2);
3238
+ };
3239
+
2988
3240
  /**
2989
3241
  * Reset the timeout.
2990
3242
  *
@@ -3087,6 +3339,8 @@ var EventEmitter = require('browser/events').EventEmitter
3087
3339
  , debug = require('browser/debug')('runner')
3088
3340
  , Test = require('./test')
3089
3341
  , utils = require('./utils')
3342
+ , filter = utils.filter
3343
+ , keys = utils.keys
3090
3344
  , noop = function(){};
3091
3345
 
3092
3346
  /**
@@ -3151,7 +3405,7 @@ Runner.prototype.grep = function(re){
3151
3405
  };
3152
3406
 
3153
3407
  /**
3154
- * Returns the number of tests matching the grep search for the
3408
+ * Returns the number of tests matching the grep search for the
3155
3409
  * given suite.
3156
3410
  *
3157
3411
  * @param {Suite} suite
@@ -3195,10 +3449,7 @@ Runner.prototype.globals = function(arr){
3195
3449
 
3196
3450
  Runner.prototype.checkGlobals = function(test){
3197
3451
  if (this.ignoreLeaks) return;
3198
-
3199
- var leaks = utils.filter(utils.keys(global), function(key){
3200
- return !~utils.indexOf(this._globals, key) && (!global.navigator || 'onerror' !== key);
3201
- }, this);
3452
+ var leaks = filterLeaks(this._globals);
3202
3453
 
3203
3454
  this._globals = this._globals.concat(leaks);
3204
3455
 
@@ -3272,6 +3523,8 @@ Runner.prototype.hook = function(name, fn){
3272
3523
 
3273
3524
  hook.run(function(err){
3274
3525
  hook.removeAllListeners('error');
3526
+ var testError = hook.error();
3527
+ if (testError) self.fail(self.test, testError);
3275
3528
  if (err) return self.failHook(hook, err);
3276
3529
  self.emit('hook end', hook);
3277
3530
  next(++i);
@@ -3519,10 +3772,15 @@ Runner.prototype.run = function(fn){
3519
3772
 
3520
3773
  debug('start');
3521
3774
 
3775
+ // uncaught callback
3776
+ function uncaught(err) {
3777
+ self.uncaught(err);
3778
+ }
3779
+
3522
3780
  // callback
3523
3781
  this.on('end', function(){
3524
3782
  debug('end');
3525
- process.removeListener('uncaughtException', this.uncaught);
3783
+ process.removeListener('uncaughtException', uncaught);
3526
3784
  fn(self.failures);
3527
3785
  });
3528
3786
 
@@ -3534,13 +3792,28 @@ Runner.prototype.run = function(fn){
3534
3792
  });
3535
3793
 
3536
3794
  // uncaught exception
3537
- process.on('uncaughtException', function(err){
3538
- self.uncaught(err);
3539
- });
3795
+ process.on('uncaughtException', uncaught);
3540
3796
 
3541
3797
  return this;
3542
3798
  };
3543
3799
 
3800
+ /**
3801
+ * Filter leaks with the given globals flagged as `ok`.
3802
+ *
3803
+ * @param {Array} ok
3804
+ * @return {Array}
3805
+ * @api private
3806
+ */
3807
+
3808
+ function filterLeaks(ok) {
3809
+ return filter(keys(global), function(key){
3810
+ var matched = filter(ok, function(ok){
3811
+ if (~ok.indexOf('*')) return 0 == key.indexOf(ok.split('*')[0]);
3812
+ return key == ok;
3813
+ });
3814
+ return matched.length == 0 && (!global.navigator || 'onerror' !== key);
3815
+ });
3816
+ }
3544
3817
  }); // module: runner.js
3545
3818
 
3546
3819
  require.register("suite.js", function(module, exports, require){
@@ -3850,22 +4123,6 @@ Test.prototype = new Runnable;
3850
4123
  Test.prototype.constructor = Test;
3851
4124
 
3852
4125
 
3853
- /**
3854
- * Inspect the context void of private properties.
3855
- *
3856
- * @return {String}
3857
- * @api private
3858
- */
3859
-
3860
- Test.prototype.inspect = function(){
3861
- return JSON.stringify(this, function(key, val){
3862
- return '_' == key[0]
3863
- ? undefined
3864
- : 'parent' == key
3865
- ? '#<Suite>'
3866
- : val;
3867
- }, 2);
3868
- };
3869
4126
  }); // module: test.js
3870
4127
 
3871
4128
  require.register("utils.js", function(module, exports, require){
@@ -4060,6 +4317,24 @@ exports.slug = function(str){
4060
4317
  .replace(/[^-\w]/g, '');
4061
4318
  };
4062
4319
 
4320
+ /**
4321
+ * Strip the function definition from `str`,
4322
+ * and re-indent for pre whitespace.
4323
+ */
4324
+
4325
+ exports.clean = function(str) {
4326
+ str = str
4327
+ .replace(/^function *\(.*\) *{/, '')
4328
+ .replace(/\s+\}$/, '');
4329
+
4330
+ var spaces = str.match(/^\n?( *)/)[1].length
4331
+ , re = new RegExp('^ {' + spaces + '}', 'gm');
4332
+
4333
+ str = str.replace(re, '');
4334
+
4335
+ return str.trim();
4336
+ };
4337
+
4063
4338
  /**
4064
4339
  * Escape regular expression characters in `str`.
4065
4340
  *
@@ -4142,10 +4417,11 @@ window.mocha = require('mocha');
4142
4417
 
4143
4418
  // boot
4144
4419
  ;(function(){
4145
- var suite = new mocha.Suite('', new mocha.Context)
4146
- , utils = mocha.utils
4420
+ var utils = mocha.utils
4147
4421
  , options = {}
4148
4422
 
4423
+ mocha.suite = new mocha.Suite('', new mocha.Context());
4424
+
4149
4425
  /**
4150
4426
  * Highlight the given string of `js`.
4151
4427
  */
@@ -4179,13 +4455,13 @@ window.mocha = require('mocha');
4179
4455
 
4180
4456
  function parse(qs) {
4181
4457
  return utils.reduce(qs.replace('?', '').split('&'), function(obj, pair){
4182
- var i = pair.indexOf('=')
4183
- , key = pair.slice(0, i)
4184
- , val = pair.slice(++i);
4458
+ var i = pair.indexOf('=')
4459
+ , key = pair.slice(0, i)
4460
+ , val = pair.slice(++i);
4185
4461
 
4186
- obj[key] = decodeURIComponent(val);
4187
- return obj;
4188
- }, {});
4462
+ obj[key] = decodeURIComponent(val);
4463
+ return obj;
4464
+ }, {});
4189
4465
  }
4190
4466
 
4191
4467
  /**
@@ -4198,9 +4474,9 @@ window.mocha = require('mocha');
4198
4474
 
4199
4475
  ui = mocha.interfaces[options.ui];
4200
4476
  if (!ui) throw new Error('invalid mocha interface "' + ui + '"');
4201
- if (options.timeout) suite.timeout(options.timeout);
4202
- ui(suite);
4203
- suite.emit('pre-require', window);
4477
+ if (options.timeout) mocha.suite.timeout(options.timeout);
4478
+ ui(mocha.suite);
4479
+ mocha.suite.emit('pre-require', window);
4204
4480
  };
4205
4481
 
4206
4482
  /**
@@ -4208,8 +4484,8 @@ window.mocha = require('mocha');
4208
4484
  */
4209
4485
 
4210
4486
  mocha.run = function(fn){
4211
- suite.emit('run');
4212
- var runner = new mocha.Runner(suite);
4487
+ mocha.suite.emit('run');
4488
+ var runner = new mocha.Runner(mocha.suite);
4213
4489
  var Reporter = options.reporter || mocha.reporters.HTML;
4214
4490
  var reporter = new Reporter(runner);
4215
4491
  var query = parse(window.location.search || "");