Performance: Testing server actions
MEDIUM IMPACT
Testing server actions impacts the speed and reliability of backend logic execution, indirectly affecting user experience by ensuring fast and correct server responses.
import { serverAction } from './actions'; jest.mock('./actions', () => ({ serverAction: jest.fn().mockResolvedValue('expected') })); test('server action fast mock test', async () => { const result = await serverAction(); expect(result).toBe('expected'); });
import { serverAction } from './actions'; test('server action slow test', async () => { const result = await serverAction(); expect(result).toBe('expected'); });
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Real server action calls in tests | 0 (server side) | 0 | 0 | [✗] Bad |
| Mocked server actions in tests | 0 (server side) | 0 | 0 | [✓] Good |