Don't write tests so religiously

This commit is contained in:
Alex Gleason 2025-06-01 21:34:11 -05:00
parent 1fc548c7e9
commit ac46749fad
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7

View File

@ -390,11 +390,7 @@ export function Post(/* ...props */) {
## Writing Tests ## Writing Tests
This project uses Vitest for testing React components. The `TestApp` component provides all necessary providers for components that use Nostr functionality, React Router, and TanStack Query. **Important for AI Assistants**: Only create tests when the user is experiencing a specific problem or explicitly requests tests. Do not proactively write tests for new features or components unless the user is having issues that require testing to diagnose or resolve.
Test files should be placed next to the module they test, using a `.test.tsx` or `.test.ts` extension:
- `src/components/MyComponent.tsx``src/components/MyComponent.test.tsx`
- `src/hooks/useCustomHook.ts``src/hooks/useCustomHook.test.ts`
### Test Setup ### Test Setup
@ -419,20 +415,6 @@ describe('MyComponent', () => {
}); });
``` ```
### Mocking Hooks
Mock custom hooks using Vitest's `vi.mock()`:
```tsx
import { vi } from 'vitest';
vi.mock('@/hooks/useCurrentUser', () => ({
useCurrentUser: () => ({
user: null, // or provide mock user data
}),
}));
```
## Testing Your Changes ## Testing Your Changes
Whenever you modify code, you must run the **test** script using the **run_script** tool. Whenever you modify code, you must run the **test** script using the **run_script** tool.