スキル一覧に戻る
grmkris

testing-patterns

by grmkris

2🍴 0📅 2026年1月24日
GitHubで見るManusで実行

SKILL.md


name: testing-patterns description: Test infrastructure patterns - PGlite for in-memory PostgreSQL, Redis/S3 mocks, TestSetup factory, Bun test. Use when writing tests or adding test infrastructure.

Testing Infrastructure

Use this skill when writing tests. Tests use isolated in-memory infrastructure.

Project Setup

Replace these placeholders for your project:

  • @project/ → your package scope (e.g., @myapp/)
  • packages/ paths follow standard monorepo layout

Expected packages:

  • @project/test-utils - In-memory infrastructure (PGlite, Redis, S3)
  • @project/shared/typeid - TypeID validators

Test File Location

  • Server tests: apps/server/test/**/*.test.ts
  • Use Bun test (describe, it, expect, beforeAll, afterAll)

Quick Start Template

import { describe, it, expect, beforeAll, afterAll } from "bun:test";
import { type TestSetup, createTestSetup } from "../test/test.setup";
import {
  createTestContext,
  createTestItem,
  fundUser,
} from "../test/test-helpers";
import { UserId } from "@project/shared/typeid";

describe("Feature Name", () => {
  let testSetup: TestSetup;

  beforeAll(async () => {
    testSetup = await createTestSetup();
  });

  afterAll(async () => {
    await testSetup.cleanup();
    await testSetup.close();
  });

  it("should do something", async () => {
    const { deps, users } = testSetup;
    const userId = UserId.parse(users.authenticated.id);

    const item = await createTestItem(deps.db, { title: "Test Item" });
    await fundUser(deps.userService, userId, 100);

    const result = await deps.itemService.create(userId, {
      itemId: item.id,
      value: "test",
    });

    expect(result.isOk()).toBe(true);
  });
});

Additional Resources

  • For TestSetup structure and in-memory infra, see setup.md
  • For test helper functions, see helpers.md

スコア

総合スコア

50/100

リポジトリの品質指標に基づく評価

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

0/10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

レビュー

💬

レビュー機能は近日公開予定です