-
-
Notifications
You must be signed in to change notification settings - Fork 350
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
Way to tag executed lines with test identifier? #597
Comments
Also, if this gets implemented, I hope that it works with instrument, since that's what I use - instrumented .js files and selenium |
would love help implementing if anyone is interested. |
I might be over simplifying it, but you already have a global variable (I forget its name, something like __ globalVar __), I thought you can just add a property called something like testName and whatever the current value of __ globalVar __.testName is recorded along with the rest of the instrumentation information, and then its up to users like me to propertly set the __ globalVar __.testName value at the start of each individual test? Is this too simple? |
@wysisoft sounds like this could work reasonably well, the global variable being set as tests run is |
Ya I might be alone on this but I think that actually knowing which test provides which coverage is critical for maintaining my code base, also for getting a good place to start when coverage is missing. |
Keep in mind that i'm the worst developer in the world. So i'd propose having another global object called coverageTests. then in addDerivedInfoForFile you add a new variable on the coverage, coverage.tl (lineTests), and populate the tests for the line. Then in the html.js detail template you add a td after the linenumber called lineTests and populate it with the values from coverage.tl |
@wysisoft I haven't thought too hard about this problem yet -- of the top of my head, I feel like you might need to modify both the testing framework and nyc to get this functionality. What I'd be tempted to do would be to set a global variable in the test suite (assuming it's not spawning any subprocesses) which would indicate the current name of the test that's running; I would then perhaps grab coverage before and after the test execution and diff the two objects -- I think this would be significantly easier than modifying the instrumenter to record this information ... it might however mean you end up writing a new module that mocha requires (or ava, tap, etc) rather than modifying nyc itself. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I'm going to close this issue for now since it's been a while - while this sounds like a cool idea it might be outside the maintainable scope of nyc for now because of the inherent complexity. I would love to be proven wrong in a PR, or even draft PR :) |
It would be really awesome if I could tell nyc/istanbul which test is currently running, and it could tag the lines of code executed with the most recent test identifier, so I know which tests are covering which code areas. Any way to make this happen?
The text was updated successfully, but these errors were encountered: