mirror of
https://gitlab.com/soapbox-pub/mkstack.git
synced 2025-08-27 13:09:22 +00:00
Don't write tests so religiously
This commit is contained in:
parent
1fc548c7e9
commit
ac46749fad
20
CONTEXT.md
20
CONTEXT.md
@ -390,11 +390,7 @@ export function Post(/* ...props */) {
|
||||
|
||||
## 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.
|
||||
|
||||
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`
|
||||
**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 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
|
||||
|
||||
Whenever you modify code, you must run the **test** script using the **run_script** tool.
|
||||
|
Loading…
x
Reference in New Issue
Block a user