-
Notifications
You must be signed in to change notification settings - Fork 7
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
Improve docs - typescript/sourcemaps #4
Comments
Did you enable
There should be a separate sourcemap file will be created: dist/maplibre-gl-dev.js
dist/maplibre-gl-dev.js.map <- sourcemap file When you start puppeteer, the page should loading the html with the scripts like: <html>
<body><script src="dist/maplibre-gl-dev.js"></script><body>
</html> // enable coverage
await page.coverage.startJSCoverage({includeRawScriptCoverage: true});
// open above html
await page.goto("http://localhost:8080/index.html");
// run your tests ...
// collect coverage data
const coverage = await page.coverage.stopJSCoverage(); |
sourcemaps are enabled, Thanks for the quick response!! |
I suppose it's possible, but isn't there an easier way to load the sourcemap? Maybe using fs API? the coverage part is executed in node basically, isn't it? |
Great! Thanks! I've published a branch and I'll look into the coverage report when the run is finished. |
This is obviously a lot better, but there's still some issues, see here for example the last closing bracket: See here the full report for this file: If I needed to guess, this is probably a source mapping issue, but I have no clue how to investigate this. |
Thanks for your suggestion. By the way, you can try the new report
there will be a
|
The original report, without the render tests (e2e) can be found here: |
Codecov can parse the json output, why should I use codecov and not json? |
Actually not, the BTW, Please try |
I don't think we can merge the coverage data with jest's. Which coverage provider do you used in jest? v8 or istanbul? |
I'm running the following line in jest: The report for codecov json is 83% coverage and for istanbul is 84% (in my PR), it seems like the difference is due to partial missing lines, the total lines is the same. |
Jest uses |
Sure, no problem. Do you know of a way to force jest to report the closing bracket as covered? |
Or is there a way to tell this tool to avoid reporting the closing brackets as not covered? I guess the problem here is, as you mentioned, the different reporting "styles" of the different tools. |
I don't think it's possible. When the coverage data provided by V8, it counts the byte ranges, so it's prefect to show the covered/uncovered ranges see v8 introduction https://v8.dev/blog/javascript-code-coverage |
So, what can I do to solve this? Is there a way for me to overcome this difference? |
You should use a unified test framework. |
I recommend using |
That doesn't make any sense, sorry... From my point of view, we are using the most popular framework for each type of test. For example the following is the mock part of the docs of playwright: We are mocking canvas, webgl, DOM, touch events etc in the unit test, if these are not solved in other test framework I don't see a good reason to change. |
Yes you are right. It is better to use Jest as the unit test tool.
see https://github.com/cenfun/monocart-coverage-reports?tab=readme-ov-file#collecting-istanbul-coverage-data |
Interesting, I'll need to understand how to properly instrument the code and make sure it works. |
Seems like the plugin has an issue with |
Yes, Instrumenting source code for Istanbul could be quite painfull. Different build tools requires different plugins, and when you use non-native JS languages such as ts, vue, may not be supported well. That's why I prefer V8. I am planning to create a new Jest reporter to generate V8 reports, see repo https://github.com/cenfun/jest-monocart-coverage |
Interesting, keep me posted, I'd be happy to take it to a test drive. |
The custom reporter of Jest has been released: https://github.com/cenfun/jest-monocart-coverage The left side is Install
|
The merge is done in codecov automaticall, but I'll look into adding this. |
I didn't know before that Codecov can merge automatically, then the third step should not be necessary.
It does support CLI, but it might not have the command you're looking for. Could you tell me about your intended use case? Perhaps it's worth implementing. |
I run coverage only as part of my CI build here: |
I understand your question now. In the command line, Jest should only be able to accept the name of the custom report, it may not be able to accept options at the next level. |
I see, I'll look into it, hopefully in the next few days and let you know if I find other places where this looks odd. |
My jest configuration has a few projects, is there a way to only configure this for a single project? |
Another note, I was hoping I could run the tests without the coverage report in some cases and with the coverage report added as a command line flag. |
Just released a new version [email protected] |
Cool! It doesn't fail, but it doesn't show the number of failed tests. |
1, raw folder contains a lot of files
|
The above link is from a PR I just opened to see how things behave: |
Thanks, |
Simply removing the import fs from "fs";
import {CoverageReport} from 'monocart-coverage-reports';
const inputDir = [
'./coverage-reports/render/raw',
'./coverage-reports/unit/raw'
];
new CoverageReport({
name: 'My Merged Coverage Report',
reports: [
['v8'],
['console-summary'],
['codecov']
],
sourceFilter: (sourcePath) => {
return !sourcePath.includes('node_modules/') && sourcePath.search(/src\//) !== -1;
},
inputDir,
outputDir: './coverage-reports/merged',
onEnd: () => {
inputDir.forEach(dir => {
fs.rmSync(dir, {
recursive: true,
force: true
})
});
}
}).generate(); |
My problem is not that it creates the folder, my problem is that I need to add the above code to my repo, which I think should be intergrated into the jest reporter package. |
Yes, I think the CLI option |
Hmm... the |
try create another config like |
Yea, I did something similar. thanks. |
Interestingly, I think the coverage for unit tests was lower by 3%, but the total was up by 3%. |
Any chance to get a new version so I won't need to add the merge code to my repo? |
You can try using 'inputDir' to merge the render test options:
|
My render tests are running in 3 different machines in the CI in parallel, parallel to the unit tests. |
If the no need merge them with MCR, Codecov will merge the reports automatically |
I must be missing out something obvious, how do I generate the |
Oh, you mean that I need to set |
Ok, do as follows: |
Got it, thanks for all the help! |
I have read what I believe is the relevant part of the docs that talks about puppeteer and also tried to implement it, but I get a report that doesn't take into consideration the source mapping.
I'm not sure what I missed in the configuration and I couldn't find anything in the readme that talks about it.
Here's how my report looks:
The code I'm using is a copy-paste of the example provided in the docs basically:
The text was updated successfully, but these errors were encountered: