-
-
Notifications
You must be signed in to change notification settings - Fork 295
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
[test-runner] Cannot read property 'decl' of undefined in coverage UI #689
Comments
Seems related to istanbuljs/v8-to-istanbul#121 |
It seems to happen when using typescript (or perhaps generally source maps). You can opt into doing coverage instrumentation with babel: https://modern-web.dev/docs/test-runner/writing-tests/code-coverage/#coverage-browser-support though this is slower. |
Thank you @LarsDenBakker, it did work, but it's kinda strange since I'm not using typescript in this project and it was running just fine with open-wc's testing-karma (I'm just upgrading my project dependencies to the new open-wc recommendations). Also if anyone is going to try the babel aproach you may need to write it a little bit different as stated here #840. |
The karma config used babel for instrumenting code as well. We switched to using chromium for speed. |
@mario-aleo @web-padawan looks like we were not on the latest version of the library. Can you try updating to the versions listed here: #935 and see if the problem is still there? And if so report a reproduction to istanbuljs/v8-to-istanbul#121 ? |
@LarsDenBakker, sorry for the late response. |
We just ran into this on a project set up with snowpack, typescript, svelte and web test runner. We have svelte component A that imports svelte component B which in turn imports typescript module C. We had 100% code coverage and then component B and module C were moved to a subdirectory inside the dir where component A is. After that module C's code coverage is 71% for functions despite no changes in the file or the test suite. When we look at the test report, we see the I tried to create a simpler setup to reproduce the error but was unable to reproduce it. It is also worth mentioning that there are some issues with snowpack and svelte sourcemaps which cause the html report to not work for svelte components but this is a typescript file seeing the issue so I am not sure if the svelte issue is to blame. |
@web-padawan @mario-aleo @LarsDenBakker I ran into this issue today with @web/test-runner. I was able to narrow it down to one class file and two test files. If any of these characteristics are changed, the coverage report works properly:
export class MyClass {
fn() {
this._ = function () {};
}
}
https://github.com/stephenwade/coverage-issue-repro To reproduce, run |
I have a minimal repro repository here: https://github.com/Stuk/wtr-coverage-repro. The details of what I believe causes this issue are listed in the readme. To summarize, metadata for functions in a file is only collected the first time that file is loaded, however some methods might only be defined when more code executed. Hence the above error when trying to access metadata for a covered function that doesn't always exist. |
Collect and merge function definitions from all runs in coverage mapping Fixes modernweb-dev#689 See also istanbuljs/v8-to-istanbul#121
…ts (#1436) Collect and merge function definitions from all runs in coverage mapping Fixes #689 See also istanbuljs/v8-to-istanbul#121
Two files in the PR for
vaadin-date-picker
have this problem:As you can see the numbers are there:
But when opening the files, I get this:
The text was updated successfully, but these errors were encountered: