-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
docs for extending mocha #56
Comments
Old issue but has there been anything done on this one? I can't manage to find any info on this and it would be really nice... |
Second the interest expressed by @TheLudd. Would really like to add a new interface but I'm finding it an absolute chore to trudge through the code to figure out how to do that. |
@dkushner @TheLudd I think both https://github.com/mochajs/mocha/wiki/Third-party-reporters and https://github.com/mochajs/mocha/wiki/Using-mocha-programmatically offer good examples of extending mocha. :) For full examples, you can try taking a look at some of the interfaces/reporters listed at https://github.com/mochajs/mocha/wiki#interfaces--reporters |
@danielstjules Well, perhaps if there also had been a "Third party ui". I have written my own now anyway but it really required looking through the code for different uis and do a lot of experimentation. I would not say this is closed but perhaps "extending" is not clearly enough defined. |
Oh, sorry! I can re-open this for now. I'll write something up on third party ui's as well. Thanks! :) |
@TheLudd While it may have been more useful a while ago, I've added a page on extending mocha with Third Party UIs, which can be found here: https://github.com/mochajs/mocha/wiki/Third-party-UIs Sorry for the wait, and thanks for mentioning it! |
Well thanks for creating it. Looks like a bit of work =) |
Yup, but only if you want the full functionality! I updated the page to include a minimal example as well, which is hopefully less daunting: var Mocha = require('mocha');
Suite = require('mocha/lib/suite'),
Test = require('mocha/lib/test');
/**
* A simple UI that only exposes a single function: test
*/
module.exports = Mocha.interfaces['simple-ui'] = function(suite){
suite.on('pre-require', function(context, file, mocha){
var common = require('mocha/lib/interfaces/common')([suite], context);
context.run = mocha.options.delay && common.runWithSuite(suite);
/**
* Describes a specification or test-case with the given `title`
* and callback `fn` acting as a thunk.
*/
context.test = function(title, fn){
var test = new Test(title, fn);
test.file = file;
suite.addTest(test);
return test;
};
});
}; |
I meant by you, creating this =) |
reporters, interfaces etc
The text was updated successfully, but these errors were encountered: