DEV Community

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

Posted on

2

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:
https://github.com/janko/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

AWS Q Developer image

Your AI Code Assistant

Ask anything about your entire project, code and get answers and even architecture diagrams. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Start free in your IDE

Top comments (1)

Collapse
 
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.

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free โ†’