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