vitest icon indicating copy to clipboard operation
vitest copied to clipboard

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

Open NullVoxPopuli opened this issue 3 years ago • 6 comments

Clear and concise description of the problem

When using describe, it can be hard to narrow tests based on files/describe blocks -- especially when test names within describe blocks / test files may be repeated.

Suggested solution

As a debug utility, it could be great to be able to output the list of tests without running them so that folks can better utilize --testNamePattern

Alternative

No response

Additional context

No response

Validations

NullVoxPopuli avatar Feb 22 '23 19:02 NullVoxPopuli

What should happen if the test name is dynamic? How can we know the name in that case? Or should we just run all test files without running test callbacks and output them?

sheremet-va avatar Oct 04 '23 12:10 sheremet-va

Or should we just run all test files without running test callbacks and output them?

yea, this is what mocha and qunit do

NullVoxPopuli avatar Oct 04 '23 12:10 NullVoxPopuli

So, basically to have a command:

vitest list -t "some pattern I have"

sheremet-va avatar Oct 04 '23 12:10 sheremet-va

Exactly, yeah

NullVoxPopuli avatar Oct 04 '23 13:10 NullVoxPopuli

Is there an output that you would expect with this command? Jest just prints file names.

sheremet-va avatar Oct 04 '23 14:10 sheremet-va

depends on output format, I suppose.

For stdout:

filename | describe | nested describe | test name
...

for json:

[
  { name: 'describe | nested describe | test name', file: 'file path' },
  ...
]

NullVoxPopuli avatar Oct 04 '23 21:10 NullVoxPopuli