cenfun / monocart-reporter

A playwright test reporter (Node.js)
https://cenfun.github.io/monocart-reporter/
MIT License
200 stars 11 forks source link

[Improve] Don't provide link to global coverage file if it's not found #71

Closed edumserrano closed 10 months ago

edumserrano commented 10 months ago

I was wondering if it was possible to NOT show the global code coverage link if the file it points to does NOT exist. I mean this link:

image

There are two cases where I see this happening:

export default defineConfig({ testDir: './tests', outputDir: './tests/test-results' ... reporter: [ ... [ 'monocart-reporter', { name: 'playwright code coverage with monocart reporter', outputFile: './tests/test-results/monocart-report.html', ... coverage: { outputDir: './tests/test-results/code-coverage', reports: [ ['lcovonly', { file: 'lcov/code-coverage.lcov.info', // path relative to coverage.outputDir }], ] } } ] ... });



Although being able to see the wrong link when a user misconfigures the code coverage options might be useful I think it's better to just hide so that it provides the correct behaviour when there is no html report being generated.

What do you think @cenfun ?
cenfun commented 10 months ago

it should be fixed in version 2.0.1, the report link should not be shown if the link file does not exist. or just set reportPath to empty

coverage: {
          outputDir: './tests/test-results/code-coverage',
          // do not show the global report link
          reportPath: "",
          reports: [...]
edumserrano commented 10 months ago

I've updated to version 2.0.1 and I can confirm this is now working as expected. Thank you @cenfun 🎉