When writing tests, avoid introducing unnecessary fakes/mocks that hide real integration behavior.
Example (minimal mocking in a hook test):
import { renderHook } from '@testing-library/react';
import { vi } from 'vitest';
const { mockDispatch } = vi.hoisted(() => ({
mockDispatch: vi.fn(),
}));
// inline mock for the second dependency to keep the hook isolated and readable
vi.mock('./some-module', () => ({
useSingleton: () => ({
dispatch: mockDispatch,
initialize: vi.fn(),
}),
}));
// renderHook(...)
Practical checklist:
Enter the URL of a public GitHub repository