-
-
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
🚀 Feature: Add option to find the call site of a test (file name and location) #4572
Comments
Let me do a proposal. I want to create and maintain a good package that provides you with the most accurate location of the call site. I've already started it here: https://github.com/nicojs/call-id. It will support all actively used browsers (as long as sauce labs or BrowserStack allows me to test them). It can be used as an ESM or CJS module, so it should be easily bundled in browser packages. I want to implement this feature in both here in mocha and jasmine (jasmine/jasmine#1884). What do you think? |
@nicojs is this still relevant given stryker-mutator/stryker-js#3504? |
Hi Josh 🙋♂️. It's very cool to see you here! 😄
Yes, it's still very relevant. Since we only know in which file the test was declared, not its location.
About the implementation. There are a couple of open questions:
|
Ok! Sorry for taking so long to answer @nicojs. The rest of the team has been quite busy and I didn't want to run roughshod over everyone when triaging nuanced issues like this. But it's been almost a year and you deserve answers. 😄
Investigation required. Unless trying it out shows the difference to be approximately 0 (i.e. that runtimes optimize it incredibly well), I'd think it definitely should be behind an option. My hunch is that we'd want the option to be opt-in at least to start.
Agreed that I think not. I don't think we want to build any source map resolution, file transpiling, etc. into Mocha. The API surface right now is mostly around importers and the like - and should stay that way.
If that ends up being how the feature would be implemented in Mocha, no problem from me. But I think we'd want to determine what the best implementation for Mocha is. Once there's a design we can figure out if a pre-existing solution like that fits in. FWIW I think
Good point! Switched. Thanks.
Good question. I'd filed #5226 on this. The current proposal I have is #5226 (comment):
But that issue is still in discussion. Anyway, cc @mochajs/maintenance-crew - I think this is a reasonable and good feature request. But I'm a little biased because I'm a fan of the Stryker project. |
Is your feature request related to a problem or a nice-to-have?? Please describe.
I would love a way to discover where tests live inside the files. Could we attach this metadata to a
Test
, orRunnable
?Describe the solution you'd like
The only generic way I can think of how to discover the location of the caller of our
it
ortest
functions is by usingnew Error().stack
. This might come with a performance penalty, so we might want to add it behind a new configuration option. Similar to Jest's--testlocationinresults
.Describe alternatives you've considered
This workaround works:
There are numerous libraries available that can parse the stack for us. Jest and tabjs are using stack-utils.
Additional context
You might have guessed it, but we want to use this new
callSite
to improve Stryker's reporting and performance 😅The text was updated successfully, but these errors were encountered: