visionmedia/mocha — pull request #301 by tricknotes (2012-03-02 08:58:01+00:00)
Title: Added reporter to `mocha.run()` as argument

I want that the test written for browser works in Travis CI without rewriting for Travis.
And to do that, it have to give `Reporter` to `mocha.run()` from context of Node.js.

I tried the following way using `zombie`.
For examples:

* test/driver.js

``` js
var express = require('express')
, app = express.createServer()
, expect = require('expect.js')
, Browser = require("zombie")
, browser = new Browser()
, _mocha = require('mocha')

app.use(express.static(__dirname+'/../'));
app.listen(8888);

browser.visit('http://localhost:8888/test/index.html', function() {
// Get `mocha` from browser context.
var mocha = browser.evaluate('mocha')
, result = mocha.run(_mocha.reporters.Spec)
app.close();
if (result.failures > 0) {
process.exit(1);
}
});
```

* test/index.html

``` html

My Tests

```

This works as my expected.

I wish that the same test works in browser and Node.js.
If you would like to my idea, please merge my patch.

Thank you:-)