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

Remove non-HTML reporters from built mocha.js #1731

Closed
ndhoule opened this issue Jun 7, 2015 · 2 comments
Closed

Remove non-HTML reporters from built mocha.js #1731

ndhoule opened this issue Jun 7, 2015 · 2 comments
Labels
area: browser browser-specific area: reporters involving a specific reporter status: wontfix typically a feature which won't be added, or a "bug" which is actually intended behavior type: chore generally involving deps, tooling, configuration, etc.

Comments

@ndhoule
Copy link
Contributor

ndhoule commented Jun 7, 2015

See #1727, #509 for details.

tl;dr: Right now the built mocha.js file includes all of the reporters, even though they aren't useful in the browser.

Seems like we should expose a browser plugin/reporter interface before we remove these, seems like we'll break https://github.com/metaskills/mocha-phantomjs/ otherwise.

cc/ @metaskills @nathanboktae

@nathanboktae
Copy link
Contributor

Yes removing the reporters will break mocha-phantomjs and mocha-casperjs - both use the compiled mocha.js and change the reporter as needed.

One thing to note too is mocha-phantomjs doesn't actually control the version of mocha. The user just points mocha-phantomjs at a flat file or server with their tests that has some version of mocha in it, so that makes life a bit tricker. mocha-casperjs does have control over it's version of mocha though. (Mocha runs in the phantomjs side in mocha-casperjs).

I've implemented ways to pull in 3rd party reporters for both projects (a bit different for both per differences in phantomjs vs the browser) - a bit hacky but it the mocha-phantomjs mechanism provides a way to require other reporters, namely the base reporter.

If per #509 the reporters were packaged separately, and this plugin mechanism was available in a robust, documented way where we could inject all the reporters included today and hook them up to the compiled version of mocha, that would work.

However the challenge is creating a a reporter that runs in node, the browser, and even phantomjs or another JavaScript environment. You can get there today with some "module magic dance" code, but perhaps we could help that situation out with a better plugin model / API.

Off the top of my head, it would look like this, for example:

(function(factory) {
  if (typeof require === 'function' && typeof module === 'object' && typeof exports === 'object') {
    // CommonJS environmnent (node, browserify, phantomjs)
    module.exports = factory(require('./Base'), require('moment'))
  } else {
    // another environment with the compiled version of mocha (e.g. Browser)
    mocha.reporter(factory(Mocha.reporters.Base, moment))
  }
})(function(Base, moment) {
  var myReporter = function MyCustomReporter() { /* ... */ }
  // ....
  return myReporter
})

@boneskull boneskull added area: reporters involving a specific reporter type: chore generally involving deps, tooling, configuration, etc. labels Jun 10, 2015
@ScottFreeCode ScottFreeCode added the area: browser browser-specific label Sep 22, 2017
@boneskull boneskull added the status: wontfix typically a feature which won't be added, or a "bug" which is actually intended behavior label Oct 18, 2017
@boneskull
Copy link
Contributor

as mentioned, headless browsers use all manner of reporters, so this is a no-go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: browser browser-specific area: reporters involving a specific reporter status: wontfix typically a feature which won't be added, or a "bug" which is actually intended behavior type: chore generally involving deps, tooling, configuration, etc.
Projects
None yet
Development

No branches or pull requests

4 participants