smithery.ai

test-service

Guide for testing service layer. Use when asked to test services. Directs to implementation-specific testing skills.

First seen Apr 3, 2026

Installation

$ npx skills add https://smithery.ai

Similar popular skills

Related neighbors and high-traction skills in the same topics — useful to compare before installing.

Also in this package

Other skills from smithery.ai · top by installs.

npx skills add https://smithery.ai

Browse all from smithery.ai

More details

Agent compatibility

Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.

Claude Code Not declared
Cursor Not declared
Codex Not declared
GitHub Copilot Not declared
Windsurf Not declared
Gemini CLI Not declared
Cline Not declared
OpenCode Not declared

Package contents

Files included with this skill beyond the listing page.

  • skill md SKILL.md 2,383 B
  • docs SUMMARY.md 136 B

History

  1. First seen on skills.sh
  2. First recorded snapshot · 1 installs

SKILL.md

Test Service

Service Types Have Different Testing Strategies

Services fall into two categories with different testing approaches:

Type Testing Strategy Skill
Resource Service Mock repository, test authorization + events test-resource-service
Utility Service Mock external APIs (fetch), test error handling test-utility-service

When to Test

Test services after you have:

  1. Created the service (create-resource-service or create-utility-service)
  2. Created any dependencies (repositories, schemas)

Which Skill to Use

Use test-resource-service when:

  • Testing services that extend BaseService
  • Testing CRUD operations on domain entities
  • Testing authorization logic (admin vs owner vs other)
  • Testing event emission

Examples: NoteService, UserService, CourseService

Use test-utility-service when:

  • Testing services that call external APIs
  • Testing authentication/authorization logic services
  • Testing error handling for external failures
  • Mocking fetch or other network calls

Examples: AuthenticationService, AuthorizationService, EmailService

Common Testing Patterns

Both service types share these patterns:

User Context Fixtures

const adminUser: AuthenticatedUserContextType = {
  userId: "admin-1",
  globalRole: "admin",
};
const regularUser: AuthenticatedUserContextType = {
  userId: "user-1",
  globalRole: "user",
};
const otherUser: AuthenticatedUserContextType = {
  userId: "user-2",
  globalRole: "user",
};

Error Assertions

// Expect specific error type
await expect(service.someMethod()).rejects.toThrow(UnauthorizedError);

// Expect any error
await expect(service.someMethod()).rejects.toThrow();

Cleanup in beforeEach/afterEach

beforeEach(() => {
  // Reset state
});

afterEach(() => {
  vi.restoreAllMocks();
});

See Also

  • test-resource-service - Testing resource services (CRUD + events)
  • test-utility-service - Testing utility services (external APIs)