Skip to content

fix(ui): auto reload coverage iframe after test run - #5242

Merged
sheremet-va merged 3 commits into
vitest-dev:mainfrom
hi-ogawa:feat-ui-reload-coverge
Feb 20, 2024
Merged

fix(ui): auto reload coverage iframe after test run#5242
sheremet-va merged 3 commits into
vitest-dev:mainfrom
hi-ogawa:feat-ui-reload-coverge

Conversation

@hi-ogawa

@hi-ogawa hi-ogawa commented Feb 20, 2024

Copy link
Copy Markdown
Collaborator

Description

I tested a simple iframe reloading and tested by pnpm -C examples/basic test:ui --coverage:

Show demo
2024-02-20.13-35-10.webm

But actually I'm worrying that there might be some race condition here:

await this.report('onFinished', this.state.getFiles(specs), this.state.getUnhandledErrors())
await this.reportCoverage(allTestsRun)

If reportCoverage takes significant time, then reloading iframe during onFinished might end up fetching old coverage html.

To avoid this race condition, it might be necessary to either:

  • add new reporter hook (like onReportCoverageFinished) just for this, or
  • move up reportCoverage before onFinished (this would likely mess up terminal output for coverage text reporter) or
  • provide a dedicated "iframe reload" button on UI, so users can at least reload it manually.

I'm leaning towards the 1st option, but what do you think?

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. If the feature is substantial or introduces breaking changes without a discussion, PR might be closed.
  • Ideally, include a test that fails without this PR but passes with it.
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.

Tests

  • Run the tests with pnpm test:ci.

Documentation

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs command.

Changesets

  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

3 participants