2.7 KiB
2.7 KiB
Testing Cheatsheet
Quick Reference
| Key | Action |
|---|---|
<leader>tt |
Run nearest test |
<leader>tf |
Run file tests |
<leader>ta |
Run all tests |
<leader>td |
Debug test |
<leader>ts |
Toggle summary |
Running Tests
<leader>tt Run nearest test (cursor position)
<leader>tf Run all tests in current file
<leader>ta Run all tests in project
<leader>tl Re-run last test
<leader>tS Stop running tests
Debugging Tests
<leader>td Debug nearest test (with DAP)
<leader>tD Debug all tests in file
Watch Mode
<leader>tw Toggle watch mode (file)
<leader>tW Toggle watch mode (nearest)
Tests auto-run when file changes.
Output & Results
<leader>ts Toggle test summary panel
<leader>to Show output for nearest test
<leader>tO Toggle output panel
Navigation
]t Jump to next failed test
[t Jump to previous failed test
Test Summary Panel
When summary is open (<leader>ts):
<cr> Jump to test
o Show output
i Show short output
O Show full output
m Mark test
M Clear marks
r Run marked/nearest
R Run all in file
d Debug test
Framework-Specific
Vitest (TypeScript)
Files detected: *.test.ts, *.spec.ts, *.test.tsx, *.spec.tsx
// Test file example
describe('MyComponent', () => {
it('should render', () => {
// cursor here, <leader>tt runs this test
})
})
Pytest (Python)
Files detected: test_*.py, *_test.py
# Test file example
def test_something():
# cursor here, <leader>tt runs this test
pass
class TestMyClass:
def test_method(self):
pass
Go Test
Files detected: *_test.go
// Test file example
func TestSomething(t *testing.T) {
// cursor here, <leader>tt runs this test
}
Common Workflows
TDD Workflow
- Write failing test
<leader>tw- Enable watch mode- Write implementation
- Test auto-runs on save
<leader>tw- Disable when done
Debug Failing Test
]t- Jump to failed test<leader>to- View output- Set breakpoint if needed (
<leader>db) <leader>td- Debug test- Step through with DAP controls
Run Specific Tests
<leader>ts- Open summarymon tests to mark themrto run marked tests
Troubleshooting
Tests Not Found
- Check file naming convention
- Verify neotest adapter is installed
- Run
:checkhealth neotest
Wrong Framework Used
- Check
testing.luafor adapter config - Ensure correct adapter is listed
Output Not Showing
<leader>tOto toggle output panel- Check if test actually ran