Skip to content

Commit

Permalink
Merge pull request mochajs#458 from joliss/suite-api
Browse files Browse the repository at this point in the history
Export top-level suite on global mocha object (mocha.suite). Closes mochajs#448
  • Loading branch information
tj committed Jun 18, 2012
2 parents a64946c + 2952bee commit a1ca706
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions support/tail.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,11 @@ window.mocha = require('mocha');

// boot
;(function(){
var suite = new mocha.Suite('', new mocha.Context)
, utils = mocha.utils
var utils = mocha.utils
, options = {}

mocha.suite = new mocha.Suite('', new mocha.Context());

/**
* Highlight the given string of `js`.
*/
Expand Down Expand Up @@ -124,18 +125,18 @@ window.mocha = require('mocha');

ui = mocha.interfaces[options.ui];
if (!ui) throw new Error('invalid mocha interface "' + ui + '"');
if (options.timeout) suite.timeout(options.timeout);
ui(suite);
suite.emit('pre-require', window);
if (options.timeout) mocha.suite.timeout(options.timeout);
ui(mocha.suite);
mocha.suite.emit('pre-require', window);
};

/**
* Run mocha, returning the Runner.
*/

mocha.run = function(fn){
suite.emit('run');
var runner = new mocha.Runner(suite);
mocha.suite.emit('run');
var runner = new mocha.Runner(mocha.suite);
var Reporter = options.reporter || mocha.reporters.HTML;
var reporter = new Reporter(runner);
var query = parse(window.location.search || "");
Expand Down

0 comments on commit a1ca706

Please sign in to comment.