Overview
Testing plugins ensures reliability and prevents regressions. This guide covers testing strategies and best practices.Testing Setup
Install Dependencies
Jest Configuration
jest.config.js
Package Scripts
package.json
Mocking Inkdown API
Create mocks for testing without Inkdown:Mock App
tests/__mocks__/inkdown-api.ts
Unit Tests
Test individual functions and methods:Testing Utilities
tests/utils.test.ts
Testing Plugin Methods
tests/plugin.test.ts
Integration Tests
Test interactions between components:tests/integration.test.ts
Manual Testing
Test Checklist
- Plugin loads without errors
- Commands appear in command palette
- Commands execute correctly
- Settings UI displays correctly
- Settings persist after restart
- Status bar items display correctly
- Event listeners work correctly
- Plugin unloads cleanly
- No memory leaks
- Works with empty workspace
- Works with large workspace
- Error messages are helpful
Platform Testing
Test on multiple platforms:- Linux
- macOS
- Windows
Edge Cases
- Empty files
- Large files (>1MB)
- Files with special characters
- Files in nested folders
- Rapid file modifications
- Plugin enabled/disabled multiple times
- Multiple instances of Inkdown
Performance Testing
Benchmark Utilities
tests/performance.test.ts
Memory Profiling
Use Chrome DevTools to profile memory:- Open Inkdown with
--inspectflag - Open chrome://inspect
- Take heap snapshots before and after operations
- Look for retained objects
Debugging
Console Logging
Error Tracking
VSCode Debug Configuration
.vscode/launch.json
Continuous Integration
GitHub Actions
.github/workflows/test.yml
Best Practices
Write Testable Code
Test Behavior, Not Implementation
Keep Tests Fast
Related
- Best Practices - Development guidelines
- Community Plugins - Publishing
- Plugin Class - Plugin API
