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

Extend existing list command to output only a list of file names #6374

Closed
4 tasks done
pleunv opened this issue Aug 21, 2024 · 3 comments · Fixed by #6392
Closed
4 tasks done

Extend existing list command to output only a list of file names #6374

pleunv opened this issue Aug 21, 2024 · 3 comments · Fixed by #6392
Assignees
Labels
p2-nice-to-have Not breaking anything but nice to have (priority)

Comments

@pleunv
Copy link

pleunv commented Aug 21, 2024

Clear and concise description of the problem

#2901 lead to the introduction of the vitest list command, but unfortunately this is pretty slow and requires some processing if you're only interested in a list of files that will run with the given filters & flags (i.e. --changed), since it parses all test files and returns a list containing every individual test case. What I ideally would want is a command that returns which files are going to be executed given the provided filters & flags without drilling down to individual test cases, requiring only a lookup and eliminating the need for a parse, thus being a lot quicker.

My main use-case for this is dynamic sharding, where I dynamically determine the amount of shards and agents I want to spin up based on a predetermined number TESTS_PER_SHARD (i.e. 100), which serves to keep the test performance stable, irregardless of number of tests. Jest for example can achieve this with --listTests [--json], which runs in under a second for ~1k test files and leads to the following output:

jest --listTests

/path/to/testA.spec.tsx
/path/to/testB.spec.tsx

jest --listTests --json

["/path/to/testA.spec.tsx", "/path/to/testB.spec.tsx"]

For comparison, running vitest list --json on an M1 MBP for the same ~1k files takes 3.5 minutes.

Suggested solution

Since there is already a dedicated list command I suppose it would make sense to provide a new optional flag, i.e. --filesOnly.

Alternative

No response

Additional context

No response

Validations

@pleunv pleunv changed the title Add new or refine existing list command to output only a list of file names Extend existing list command to output only a list of file names Aug 21, 2024
@sheremet-va
Copy link
Member

since it parses all test files and returns a list containing every individual test case

It doesn't parse it, it runs the code to collect tests. This is what mocha does for example.

@sheremet-va sheremet-va added p2-nice-to-have Not breaking anything but nice to have (priority) and removed enhancement: pending triage labels Aug 21, 2024
@Ma-hawaj
Copy link
Contributor

Can I try working on this ?

@sheremet-va
Copy link
Member

Can I try working on this ?

Sure

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p2-nice-to-have Not breaking anything but nice to have (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants