question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Run only the test with the given name with `-t` and `--testNamePattern`

See original GitHub issue

Clear 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

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
remorsescommented, Dec 23, 2021

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 testName

Also, 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

0reactions
sheremet-vacommented, Dec 29, 2021

Implemented in 0.0.118

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found