-
-
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
Expose the globals as modules in mocha. #1077
Conversation
hmm personally I'd rather export them in mocha than have tons of files |
otherwise LGTM |
+1 on exposing them as part of the mocha namespace, -1 on multiple files |
wow. such files. |
+1 on this happening either as files or in namespace, will take either |
+1 under mocha's namespace @Raynos wanna update your changes? |
@guille @travisjeffery the beautiful, beautiful files :( I exposed them in lib/mocha.js instead. |
@visionmedia is this good to go? |
@Raynos no, they're undefined there since the methods aren't put on global until |
@travisjeffery that shouldn't matter. I require |
run it. that |
Ok, I'll look into it, add a test case and make sure it actually works. The multiple files approach would have just worked for free :P |
@travisjeffery you were right. I added a test! It works now. @visionmedia is there a place where i can PR the docs for mocha itself ? there not in this repo as far as I can see. |
@travisjeffery because we have have redefined Without the fix (moving the exports in the event listener) it will fail. I'll happily update it so that it bootstraps the mocha suite runner if it hasn't been bootstrapped by the time its required. then tests can be run with The point of this fix is to not have globals in your test files even if you run the tests with |
I've thought about how to get mocha working with I could probably get it to work with |
+1 – very good PR imho |
Expose the globals as modules in mocha.
👍 @Raynos docs are in the gh-pages branch. |
@travisjeffery thanks! I've added a PR into the gh-pages to document this feature. |
@travisjeffery @guille if you could bump the minor / patch version and publish this then that would be great :) |
This change allows you to write mocha tests without referencing globals in your test files.
This is useful when you want to lint your tests and your linter complains about globals.
For example
This also has a benefit of being able to write mocha tests in either the BDD or the TDD style by just requiring either
test
orit
and the command line setting of the interface is irrelevant.