Back to skills
SkillHub ClubShip Full StackFull StackFrontendBackend

testing-server-actions

Teaches testing Server Actions in isolation in React 19. Use when testing Server Actions, form handling, or server-side logic.

Packaged view

This page reorganizes the original catalog entry around fit, installability, and workflow context first. The original raw source lives below.

Stars
0
Hot score
74
Updated
March 19, 2026
Overall rating
C2.2
Composite score
2.2
Best-practice grade
S96.0

Install command

npx @skill-hub/cli install djankies-claude-configs-testing-server-actions

Repository

djankies/claude-configs

Skill path: react-19/skills/testing-server-actions

Teaches testing Server Actions in isolation in React 19. Use when testing Server Actions, form handling, or server-side logic.

Open repository

Best for

Primary workflow: Ship Full Stack.

Technical facets: Full Stack, Frontend, Backend, Testing.

Target audience: everyone.

License: Unknown.

Original source

Catalog source: SkillHub Club.

Repository owner: djankies.

This is still a mirrored public skill entry. Review the repository before installing into production workflows.

What it helps with

  • Install testing-server-actions into Claude Code, Codex CLI, Gemini CLI, or OpenCode workflows
  • Review https://github.com/djankies/claude-configs before adding testing-server-actions to shared team environments
  • Use testing-server-actions for development workflows

Works across

Claude CodeCodex CLIGemini CLIOpenCode

Favorites: 0.

Sub-skills: 0.

Aggregator: No.

Original source / Raw SKILL.md

---
name: testing-server-actions
description: Teaches testing Server Actions in isolation in React 19. Use when testing Server Actions, form handling, or server-side logic.
allowed-tools: Read, Write, Edit
version: 1.0.0
---

# Testing Server Actions

For Vitest mocking patterns (vi.mock(), vi.fn(), mockResolvedValue), see `vitest-4/skills/writing-vitest-tests/SKILL.md`.

## Basic Server Action Test

```javascript
import { submitContact } from './actions';

test('submitContact validates email', async () => {
  const formData = new FormData();
  formData.set('email', 'invalid');
  formData.set('message', 'Hello');

  const result = await submitContact(null, formData);

  expect(result.error).toBeTruthy();
});

test('submitContact succeeds with valid data', async () => {
  const formData = new FormData();
  formData.set('email', '[email protected]');
  formData.set('message', 'Hello');

  const result = await submitContact(null, formData);

  expect(result.success).toBe(true);
});
```

## Mocking Database Calls

```javascript
import { createUser } from './actions';
import { db } from './db';

vi.mock('./db', () => ({
  db: {
    users: {
      create: vi.fn(),
    },
  },
}));

test('createUser creates database record', async () => {
  db.users.create.mockResolvedValue({ id: '123', name: 'Alice' });

  const formData = new FormData();
  formData.set('name', 'Alice');
  formData.set('email', '[email protected]');

  const result = await createUser(null, formData);

  expect(db.users.create).toHaveBeenCalledWith({
    name: 'Alice',
    email: '[email protected]',
  });

  expect(result.success).toBe(true);
  expect(result.userId).toBe('123');
});
```

## Testing with Authentication

```javascript
import { deletePost } from './actions';
import { getSession } from './auth';

vi.mock('./auth');

test('deletePost requires authentication', async () => {
  getSession.mockResolvedValue(null);

  await expect(deletePost('post-123')).rejects.toThrow('Unauthorized');
});

test('deletePost checks ownership', async () => {
  getSession.mockResolvedValue({ user: { id: 'user-1' } });

  await expect(deletePost('post-owned-by-user-2')).rejects.toThrow('Forbidden');
});
```

For comprehensive Server Action testing, test the function directly in isolation.

## References

- [@vitest-4/skills/writing-vitest-tests](/vitest-4/skills/writing-vitest-tests/SKILL.md) - Mocking and spy patterns
testing-server-actions | SkillHub