-
Notifications
You must be signed in to change notification settings - Fork 2
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
Export globally mocha
and runner
instances
#4
Conversation
No, thank you for the kind words. 😀 I'm genuinely flattered knowing this test-runner's helping other people in their projects too. 😉 Regarding "coverage"... that's not something I have much knowledge in, and I've been interested in reading up on it more to learn how it works. So if this gets |
Alright mate, it looks good to me. 😀 Just some questions. In particular, I'd like to ask about the necessity to have globalise a Is this the API you'd need to hack into to track test coverage? =) If not, I'm happy to sit down and add more formal support for coverage generation. |
I'll try to give you a mini briefing about code coverage...
Using a coverage tool needs two more steps: one intermediate and another at the end. The coverage tool needs to instrument your source code (the one being tested, not your specs). In my case,
Thus, the coverage tool needs to transform (instrument) your source code, so it can collect the previous info accurately. Note that these instrumented files are different from your original source code. Once you have instrumented your source files, then it's time to run your specs requiring/using those instrumented files, so when your test-runner (
So I can start now answering your questions...
I need (2), which is the returned value from invoking That's how the coverage info can be collected when the So the final workflow could be as follow:
I think the confusion comes from your assignment of the Anyway, I've just found a way to get the coverage without exporting any globals, but I think it would be useful to provide those globals of this PR to allow developers to customize the behavior of their specs through the I apologize for the long explanation, but I think it's the best way I can explain what I was trying to do, and hope it helps you understanding how code coverage works, because I found no short-guide like this nowhere when I started. |
Damn. Thanks so much for the comprehensive write-up! 😀 I really appreciate the time you put in to offer me a clear explanation. Seriously.
How did you achieve that? What we should be doing (I think) is globalising the That should be enough to cover our coverage needs, I should hope? ;) Just an FYI: this module's entire API is due for complete overhaul. Feel free to offer your thoughts. |
You're welcome!
Well, summarizing it: now I feed I will share you the github repo URL of my package (which is a fork of
That would be a great solution indeed. I noticed that Later I'll make the changes and test them. If succeed, will push them and rebase 😉
I saw it early in the morning, but didn't give it a read. For sure I will offer you any thought I will come up with. |
Excellent, thanks again! ;D
It's actually this, I think: 😕 Nowhere else in the code is |
I've just checked that Tomorrow I'll rewrite the PR. I'm exhausted by today 😉 |
@Alhadis Just commited the changes and rebased to have only one commit to review. I've just checked locally that it works! Waiting for your review comments 😉 |
Thanks so much! 😀 You've been both patient and helpful. I'm also going to drop that ugly code-injection hack I used for implementing the "open filenames by clicking their names in stack traces" feature. Atom have since added a proper API for doing this sort of thing. |
Welcome! FYI, I've been reading your open issue, but I feel still a bit poor-skilled on Atom issues to offer you some useful thoughts. I'm just deep learning to code Atom packages, so hopefully I will lend you a hand to improve this package (if you want) after acquiring some more skills on this topics 😉 |
Honestly, when I finally get around to rehauling and properly documenting the package's APIs, your opinion on what feels right and what feels weird will be most valuable. 😀 This project started because I needed a functional, responsive, non-frustrating interface for running package tests as I worked on Since those features involved dangerous, risky hacks of core package code, I needed to make sure test-coverage was airtight. Most importantly, I needed to see what went wrong when a test failed. Because the test-runner was such a damn success, I wanted others to use and enjoy it too. But I haven't exactly promoted it or anything... so I've not had many users or much feedback to go by ;) BTW, haven't cut a release yet because I'm wrapping up a PR. Will do so soon, don't worry. 😉 Unrelated trivia:
|
I am happy to bring any feedback on this. I am very pleased with the possibility of having coverage reports into project-viewer-plus. Although I am strugling to have the coverage reporting :\ examples? |
@jccguimaraes and any other developer searching for adding code coverage reports to their Atom packages... I am working right now on developing an easy-to-mimic-workflow to get it. Right now it works for me, but I'm polishing it to be as easy as running That's a lot of things to mix up. I hope pushing soon that polished workflow into I'm just commenting this here to avoid polluting this PR thread, since it has served its purposed and it's merged. I prefer @Alhadis not to be bothered with notifications of something that isn't directly related to his project.
Just watch for my repo. It's too long to explain, and some hackity hacks are needed to get it working. You will have a fully working example in the next one or two weeks (or even before!). |
sure! amazing work! keep on |
Sorry for taking so long to cut the release. 😞 |
Thanks to you, @Alhadis !! I was ready to ask you for that, because I've decided to release a NPM package for the coverage of Atom packages (so other users as @jccguimaraes can benefit of my approach), and I've set yours as a peer dependency which is currently pointing to the master branch of your repo. Setting up a semver string is better, so thanks again!! 😉 |
De nada! 😉 And yes, |
For sure! But thanks for the reminder anyway! |
great work guys |
@Alhadis I've finally pushed my package to GitHub. It relies on this EDIT: @jccguimaraes take a look at that package, and let me know if you have any issues by opening an issue there! |
I've given it your first star. 😀 Thanks for the heads up! I'll admit your use of this has inspired me to make this more accessible to those running unit tests with Mocha, irrespective of whether those tests are even Atom/Electron-specific in nature. 😉 Hope to resume work on this some day. :D |
@Alhadis Thank you very much! Glad to have a positive influence on you 😊 Pin me whenever you resume your work 😉 . Hopefully I can offer you some insights to improve your package. Right now I'm integrating my own package with lots of cloud services to ensure quality/security (snyk, greenkeeper, bithound, codecov, coveralls, inch-ci) and configuring CI builds/checks (travis, appveyor). Most of those cloud services are free for open source projects, and offer an invaluable information (at least to me). If you are interested in these things, let me know and I'll post them at #3 |
First of all, thank you very much for your efforts and making this awesome package open source!
I'm using it to get code coverage for my Atom package, and I need the
mocha
andrunner
instances available to hook my coverage collector into them.As you can see, the changes are minimal and doesn't change any default functionality.
Here you can read about those hooks I need. Summarizing:
global.mocha.runner.on('end', cb)
with this PR.global.mocha.instance.beforeAll(cb)
with this PR.Hope you found it useful and merge it to this awesome package.
I'm here for any improvements/corrections/issues you may have!