Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make vitest fail fast after first known test failure

I am using Vitest for testing and would like it to fail fast upon first error. The reason is that I'm using it within git bisect and don't need to waste time on the whole test run once there is an error.

I haven’t found an equivalent in Vitest. How can I configure Vitest or work around this to achieve similar functionality?

like image 665
Cornelius Roemer Avatar asked Oct 16 '25 04:10

Cornelius Roemer


1 Answers

The option is called --bail, passing --bail=1 makes vitest fail after first failure:

vitest --bail=1

From the docs:

bail
Type: number
Default: 0
CLI: --bail=<value>

Stop test execution when given number of tests have failed.

By default Vitest will run all of your test cases even if some of them fail. This may not be desired for CI builds where you are only interested in 100% successful builds and would like to stop test execution as early as possible when test failures occur. The bail option can be used to speed up CI runs by preventing it from running more tests when failures have occurred.

from https://vitest.dev/config/#bail

like image 156
Cornelius Roemer Avatar answered Oct 17 '25 18:10

Cornelius Roemer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!