Skip to content
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 should be refreshed in the UI when tests are re-run #3504

Closed
4 tasks done
sdelpuerto-intelygenz opened this issue Jun 4, 2023 · 5 comments · Fixed by #3508 or #3529
Closed
4 tasks done

Coverage report should be refreshed in the UI when tests are re-run #3504

sdelpuerto-intelygenz opened this issue Jun 4, 2023 · 5 comments · Fixed by #3508 or #3529

Comments

@sdelpuerto-intelygenz
Copy link

sdelpuerto-intelygenz commented Jun 4, 2023

Clear and concise description of the problem

When running vitest with the --ui and --coverage options, there is no convenient way to see changes to the coverage report through the UI.

Suggested solution

It would be great if the coverage report was refreshed every time it's updated, just like the test results are, without user intervention.

Alternative

Alternatively, the currently open report could be synced to the URL. That way the user can refresh the window and not have to navigate back to the report they were looking at earlier, but this still requires user intervention.

Additional context

The way it currently works, I'd rather have a new tab open when I click on the coverage button on the UI, rather than show an iframe that doesn't automatically refresh or stay synced with the URL. Being able to have this behavior could also be a potential solution.

Validations

@userquin
Copy link
Member

userquin commented Jun 4, 2023

since coverage is static we'll need to add no cache headers for any resource in the middleware, working on it...

@sdelpuerto-intelygenz
Copy link
Author

Thanks for looking into this. Since your changes haven't been released yet, I tried them locally with a PNPM patch, but the coverage report still doesn't refresh for me. Am I missing anything?

@userquin
Copy link
Member

userquin commented Jun 6, 2023

@sdelpuerto-intelygenz maybe we should add some random/timestamp in the iframe coverage url:
https://github.com/vitest-dev/vitest/blob/main/packages/ui/client/pages/index.vue#L30

Something like this in root page:

const useCoverageUrl = computed(() => {
  // force change coverage url
  return coverageVisible.value ? `${coverageUrl.value}?v=${Math.random()}`: `${coverageUrl.value}?v=${Math.random()}`
})
</script>

then change also src attr:

          <Coverage v-else-if="coverageVisible" key="coverage" :src="useCoverageUrl" />

@sheremet-va sheremet-va reopened this Jun 6, 2023
@userquin
Copy link
Member

userquin commented Jun 6, 2023

cannot reproduce it:

imagen

imagen

undoing changes, re-running tests and selecting again the coverage works: myabe we can send the user to dashboard when re-running all or some tests forcing the user to select coverage again.

@userquin
Copy link
Member

userquin commented Jun 6, 2023

if you're on the coverage page, it will not refresh, I'll try to reload coverage page once re-run finish...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants