-
-
Notifications
You must be signed in to change notification settings - Fork 74
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
Add code coverage #263
Add code coverage #263
Conversation
✅ Deploy Preview for monaco-yaml ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
6bc61c0
to
d308db1
Compare
d308db1
to
3e9ca0b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like monaco-editor
is running your code on Worker
. Is it possible to force it load in main thread instead?
- Add flag to Disable Worker microsoft/monaco-editor#380
- [Bug] How to disable worker loading microsoft/monaco-editor#4795
Adding following raises a warning from monaco but it still runs into some errors:
window.MonacoEnvironment ||= {}
window.MonacoEnvironment.getWorker = undefined
> Could not create web worker(s). Falling back to loading web worker code in main thread, which might cause UI freezes. Please see https://github.com/microsoft/monaco-editor#faq
> Error: Cannot read properties of undefined (reading 'toUrl')
Vitest's browser mode is unable to collect coverage from Workers. This is also not possible in Playwright - how did you do this before using Vitest? It should be possible to add support for this in Vitest, we just haven't implemented it yet.
@vitest/web-worker
error when using browser environment vitest-dev/vitest#4899- [Feature] CDPSessions for Web Workers microsoft/playwright#22992
Maybe using packages like https://www.npmjs.com/package/pseudo-worker could work here?
Thanks! It is possible to run builtin workers on the main thread, but not Code coverage isn’t working for code outside workers either. This may have to do with the fact that I’m testing build output, but I’m interested in coverage for source code. It looks like Vitest doesn’t use the source map to map coverage of the build output back to the original source code. This is my main goal. Improving coverage to include web worker support is a nice to have follow-up. I believe the tests should be as close to the user as possible. This means testing the code that’s published, not the code that’s authored. This is especially true for Before Vitest with Playwright I didn’t have code coverage either. Having code coverage at all would be a great improvement, even if it doesn’t work for web workers yet. |
It does use. You'll need to add the built files in |
Ooh I see! It works, thanks! So I need to:
The coverage is wrong though. It’s pretty easy to spot, because it reports lines 429-436 of |
It feels a bit unintuitive that
This was indeed locally. I removed and reinstalled These warnings do concern me though: The missing source files are probably due to badly packaged dependencies. But the optimized dependencies look like they might be bad for reasons I don’t understand. It seems to point to all runtime dependencies I use. What does the warning mean? Can I tell Vitest to optimize all deps? |
Those dependencies should be added in the config. It's not ideal but as far as I know, there are no better solutions at the moment. I'm not sure what tool is causing those source map warnings. 🤔 |
We only need one coverage provider
I’m not sure what tools, but the violating package is |
No description provided.