Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added optional support for setting global hooks in the browser during setup #111

Closed
wants to merge 3 commits into from

Conversation

garth
Copy link

@garth garth commented Dec 2, 2011

Example:

mocha.setup('bdd', {
  fail: function(test) { console.log(test); },
  end: function(status) { console.log(status); }
});

mocha.run();

Useful for custom actions on success/failure/completion such as sending status to the server when auto-running a suite in multiple browsers

  mocha.setup('bdd', {
    fail: function(test) { console.log(test); },
    end: function(status) { console.log(status); }
  });
  mocha.run();

Useful for custom actions on success/failure/completion such as
sending status to the server
@tj
Copy link
Contributor

tj commented Dec 3, 2011

i'd rather just expose the runner so you can listen on any event without any duplicate effort

@garth
Copy link
Author

garth commented Dec 3, 2011

Yes, I thought about that too, but I also wanted pass along the Base.stats to the end function, but then you'd have to expose some more ugly bits too and end up with more complex api.

Any suggestions?

@garth
Copy link
Author

garth commented Dec 3, 2011

Of course this commit will work for any event on the runner.

@tj
Copy link
Contributor

tj commented Dec 3, 2011

IMO mocha.run() should return the Runner, and should be passed the the reporter, defaulting to HTML like it is right now, so you would do:

var reporter = new mocha.reporters.HTML;
var runner = mocha.run(reporter);

runner.on('whatever', dosomerthingwithreporter);

@tj
Copy link
Contributor

tj commented Dec 15, 2011

mocha.run() now returns the runner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants