← スキル一覧に戻る
Use
Use

test-service
by madooei
This is a template for a backend service built with TypeScript and Hono.js. It provides a basic structure for creating RESTful APIs.
⭐ 1🍴 0📅 2026年1月5日
SKILL.md
name: test-service description: Guide for testing service layer. Use when asked to test services. Directs to implementation-specific testing skills.
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:
- Created the service (
create-resource-serviceorcreate-utility-service) - 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
fetchor 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)
スコア
総合スコア
70/100
リポジトリの品質指標に基づく評価
✓SKILL.md
SKILL.mdファイルが含まれている
+20
✓LICENSE
ライセンスが設定されている
+10
✓説明文
100文字以上の説明がある
+10
○人気
GitHub Stars 100以上
0/15
○最近の活動
3ヶ月以内に更新がある
0/10
○フォーク
10回以上フォークされている
0/5
✓Issue管理
オープンIssueが50未満
+5
✓言語
プログラミング言語が設定されている
+5
○タグ
1つ以上のタグが設定されている
0/5
レビュー
💬
レビュー機能は近日公開予定です