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

Reporter should group workspaces and be order consistent #7293

Open
4 tasks done
kevinmarrec opened this issue Jan 19, 2025 · 4 comments
Open
4 tasks done

Reporter should group workspaces and be order consistent #7293

kevinmarrec opened this issue Jan 19, 2025 · 4 comments
Labels
enhancement: pending triage feat: reporters Issues and PRs related to Vitest reporters

Comments

@kevinmarrec
Copy link

kevinmarrec commented Jan 19, 2025

Clear and concise description of the problem

In the following screenshot, we can see that using Vitest workspaces can lead to unordered/splitted/mixed test suites across workspaces.

Indeed, due to parallel testing, final output is not always correctly ordered and can therefore be inconsistent across runs.

It makes it unfriendly to read, and could be improved.

Image

Suggested solution

I would like a way to make Vitest, when finishing parallel testing and updating the interface for the last time, to group up everything by workspace then by alphabetical unit test suite name / file.

Alternative

No response

Additional context

I'm using simple Workspace configuration in a monorepo :

import { defineConfig } from 'vitest/config'

export default defineConfig({
  test: {
    workspace: ['packages/*'],
    reporters: ['verbose'],
  },
})

Validations

@kevinmarrec kevinmarrec changed the title Reporter should group Reporter should group workspaces and be order consistent Jan 19, 2025
@AriPerkkio
Copy link
Member

Those results are reported immediatelly after a test file has finished running. In order to be able to group them, we would need to delay reporting only to the end. That doesn't sound like good developer experience.

You can always create a custom reporter that doesn't do any reporting during test run. See https://vitest.dev/advanced/api/reporters.html.

@AriPerkkio AriPerkkio added the feat: reporters Issues and PRs related to Vitest reporters label Jan 19, 2025
@kevinmarrec
Copy link
Author

kevinmarrec commented Jan 19, 2025

@AriPerkkio Isn't the interface updated on the go during parallel testing ? Can't we refresh at the end with final updated report ? My request most probably should be considered under an option flag, as it may affect a little the performance (grouping + update interface for final report overhead).

I think it's totally achievable with a custom reporter, but it would be preferrable to be an opt-in option of the default and/or verbose reporters.

@AriPerkkio
Copy link
Member

AriPerkkio commented Jan 19, 2025

Isn't the interface updated on the go during parallel testing ?

Only a small part of the terminal is updated during test run. The completed test files and their test cases are rendered just once. These are never updated.

Can't we refresh at the end with final updated report ?

Terminals allow only updating content that is currently visible. So anything that's visible only when scrolled up cannot be updated. Though it is possible to clear whole terminal and the scrollback buffer. It would mean that any previous commands you ran before Vitest would be erased too.

So here it would be possible to clear whole terminal at the end of run and print sorted results. Console logs and other warnings would be lost though.

Or then just print sorted results without erasing the terminal.

@kevinmarrec
Copy link
Author

@AriPerkkio I see, makes sense.

Still, it's already 100% working in Vitest UI :

Image

But there we're not limited as it's web and everything can be updated.

I'm just missing the same consistence in the terminal, and wishing we can find a solution, but we may just be limited by how work terminals afterall.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement: pending triage feat: reporters Issues and PRs related to Vitest reporters
Projects
None yet
Development

No branches or pull requests

2 participants