Run only the test with the given name with `-t` and `--testNamePattern`
See original GitHub issueClear and concise description of the problem
There is no way to run only a specific test from a file
Suggested solution
Run only the test with name x using vitest -t x
Alternative
No response
Additional context
This would also make possible to use vitest with the jest vscode extension adding { "jestrunner.jestPath": "node_modules/vitest/vitest.mjs" } to vscode settings.json
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn’t already an issue that request the same feature to avoid creating a duplicate.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Trying to use -t or --testNamePattern in Jest runs all tests
Auth' which is the name of the test, then every test runs, including all with no name string like what is specified. Same...
Read more >Two useful ways to easily run a single test using Jest
Easily run a single test using Jest with .only or -t CLI paramter. They are also useful to run specific tests.
Read more >testNamePattern and negative pattern #5882 - facebook/jest
Run only tests and test suites with a name that matches the regex. For example, suppose you want to run only tests related...
Read more >Jest CLI Options
Run only the tests that were specified with a pattern or filename: jest my-test #or jest path/to/my-test.js. Run tests related to changed ...
Read more >unittest — Unit testing framework — Python 3.11.1 ...
Only run test methods and classes that match the pattern or substring. This option may be used multiple times, in which case all...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

But this way there is no way to run a test only on a file with the given name, right? something like
vitest file.test.ts -t testNameAlso, i think it’s a bit confusing imo, it would be better to stick with jest cli conventions given that most people are familiar with that
Implemented in 0.0.118