Skip to content

Commit

Permalink
fix(browser): support coverage.reportsDirectory with multiple direc…
Browse files Browse the repository at this point in the history
…tories
  • Loading branch information
AriPerkkio committed Jan 28, 2024
1 parent b1462a4 commit 89e498d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/ui/client/composables/navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,18 @@ export const coverageEnabled = computed(() => {
// Handling other cases seems difficult, so this limitation is mentioned in the documentation for now.
export const coverageUrl = computed(() => {
if (coverageEnabled.value) {
const idx = coverage.value!.reportsDirectory.lastIndexOf('/')
const htmlReporter = coverage.value!.reporter.find((reporter) => {
if (reporter[0] !== 'html')
return undefined

return reporter
})

const reportsDirectory = coverage.value!.reportsDirectory.replace(config.value!.root, '')

return htmlReporter && 'subdir' in htmlReporter[1]
? `/${coverage.value!.reportsDirectory.slice(idx + 1)}/${htmlReporter[1].subdir}/index.html`
: `/${coverage.value!.reportsDirectory.slice(idx + 1)}/index.html`
? `${reportsDirectory}/${htmlReporter[1].subdir}/index.html`
: `${reportsDirectory}/index.html`
}

return undefined
Expand Down

0 comments on commit 89e498d

Please sign in to comment.