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

feat!(vitest): add "vitest list" command to output test names #4240

Closed
wants to merge 8 commits into from

Conversation

sheremet-va
Copy link
Member

@sheremet-va sheremet-va commented Oct 4, 2023

Description

Closes #2901

This PR adds a new command:

vitest list

It outputs the list of tests that would be running with passed-down filters. For example, like this:

vitest list filename another-filename -t "some kind of filter"

By default, it just prints a list of names to stdout. You can pass down --json flag to output it as json (it will also include a filename as a separate field). --json flag also accepts a path to the file: vitest list --json=./tests.json

This PR also adds a new config option called collectors which has the same interface as a reporter - so you can collect tests in real-time (onCollected will be called after each test file is collected). This will probably be useful for tools like VS Code extension.

To improve performance, Vitest ignores "isolate" flag (always set to false), unless it's overridden in CLI.

TODO:

  • Update browser peer dependency
  • Documentation

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:.

@netlify
Copy link

netlify bot commented Oct 4, 2023

Deploy Preview for fastidious-cascaron-4ded94 failed.

Name Link
🔨 Latest commit b1767a4
🔍 Latest deploy log https://app.netlify.com/sites/fastidious-cascaron-4ded94/deploys/651ea37aaa0fa6000820efa7

@sheremet-va
Copy link
Member Author

Currently, it cannot exit for some reason (investigating). The output itself is not here yet. A few questions, @NullVoxPopuli:

  • Do we output the banner? ([RUN] Vitest 1.0.0)
  • Do we output test names while collecting them?
  • How does the finished output look like?

@NullVoxPopuli
Copy link

Do we output the banner?

seems fine for stdout

Do we output test names while collecting them?

I don't think there is a need to stream any output if that's easier -- we wouldn't be running the tests themselves, so collecting everything to output at once should be very fast.

How does the finished output look like?

Potentially: #2901

@marilari88
Copy link

Hi @sheremet-va! As the Vitest adapter maintainer for Neovim, I was thrilled about this PR. It seems like a game-changer for resolving issues related to test discovery, especially for parameters tests.

Any chance you could provide a quick update on its status? I believe this integration is crucial for everyone developing tools upon Vitest. Your work is greatly appreciated!

@sheremet-va
Copy link
Member Author

Hi @sheremet-va! As the Vitest adapter maintainer for Neovim, I was thrilled about this PR. It seems like a game-changer for resolving issues related to test discovery, especially for parameters tests.

Any chance you could provide a quick update on its status? I believe this integration is crucial for everyone developing tools upon Vitest. Your work is greatly appreciated!

I am planning to have a release with changes to how pools are working in Vitest. Since Vitest API is experimental, it will not be a breaking change. I cannot give you the timing, but it will be after Vitest 1.0.

@sheremet-va sheremet-va added this to the 1.2.0 milestone Dec 9, 2023
@sheremet-va sheremet-va modified the milestones: 1.2.0, 2.0.0 Jan 3, 2024
@sheremet-va sheremet-va changed the title feat(vitest): add "vitest list" command to output test names feat!(vitest): add "vitest list" command to output test names Jan 3, 2024
@sheremet-va sheremet-va removed this from the 2.0.0 milestone Jun 23, 2024
@sheremet-va sheremet-va deleted the feat/command-list branch June 23, 2024 16:10
@sheremet-va
Copy link
Member Author

It's implemented in another PR: #6013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add CLI command to output a list of tests for better testNamePattern usage
3 participants