DEV Community

Cover image for Instant test feedback with vim-test
Vasily Polovnyov
Vasily Polovnyov

Posted on

Instant test feedback with vim-test

Alt Text

I'm a huge fan of instant feedback in tests: the faster I get test results, the faster I get back to the code, the faster I get work done. To do this, I use watchers: in Ruby Guard tracks changes in files and automatically runs the right specs, in JavaScript jest --watch does it.

Over time, watchers began to annoy me: you save the file, the test runs after two seconds. Those two seconds are an eternity. Often you think you haven't saved the file, you save it again. The test runs a couple more times.

So I switched to running the tests manually but instantly with vim-test:

The idea is simple: save the spec, hit "space t" (space is a leader), immediately get a terminal with the test results. Awesome instant feedback.

P. S. I use these shortcuts to run the tests:

nnoremap <silent> <Leader>t :TestFile<CR>
nnoremap <silent> <Leader>s :TestNearest<CR>
nnoremap <silent> <Leader>l :TestLast<CR>
Enter fullscreen mode Exit fullscreen mode

Top comments (1)

elliotekj profile image
Elliot Jackson

Big fan of vim-test too! For even faster feedback you could output your test results to a quickfix split with vim-dispatch (by setting let test#strategy = "dispatch") and use the usual quickfix commands to quickly navigate through your failed tests.