-
-
Notifications
You must be signed in to change notification settings - Fork 291
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
Coverage report is not correct when Rollup Inject is used #2778
Comments
Does |
Thanks for your comment. No sure if I got your point. Are you asking if the 2 offset lines correlate with the amount of lines added by Regarding the I reported it here first because the docs stated that the plugin was "tested to work correctly". Could it also be an issue with |
These plugins are tested to work correctly with Web Dev Server and there is some assumption that this also means that they work with Test Runner and all of its associated options, but clearly something was missed or changed over time. So, thanks for bringing this up! The lines being exactly the lines added by inject implies that it will be an issue with that plugin; possibly on their end, possibly on ours. It would be good to check with them to see if their changes are passed into source map tooling that would be needed to ensure the lines match up from the actual code under test vs the source. |
Tip TLDR: I tried to build a small reproducer only with When debugging
$("");
import inject from '@rollup/plugin-inject';
/**
* @type {import("rollup").RollupOptions}
*/
export default {
input: 'src/index.mjs',
output: {
sourcemap: true,
dir: 'output'
// format: 'cjs'
},
plugins: [
inject({
"$": "jquery"
// Promise: ['es6-promise', 'Promise']
})
]
};
npx rollup -c
import $ from 'jquery';
$("");
//# sourceMappingURL=index.js.map
{
"version": 3,
"file": "index.js",
"sources": [
"../src/index.mjs"
],
"sourcesContent": [
"$(\"\");"
],
"names": [],
"mappings": ";;AAAA,CAAC,CAAC,EAAE,CAAC"
} Used a source-map-visualization to validate the source map generated and got the following: |
I'm currently migrating from Karma to Web-test-runner. When using Rollup Inject, some files get modified to include additional
import
lines. This additions are not taking into consideration when generating the coverage report. The result of this is that covered/uncovered lines are not correct (offset depending on the amount of lines added).Examples
Karma (correct):
Web-test-runner:
Is this a bug, or is there any other plugin that may fix this issue?
Current plugins:
The text was updated successfully, but these errors were encountered: