本文へ移動
cccskills
無料GitHub で公開

testing

Testing and code quality context for Jest, React Testing Library, ESLint, and test patterns. Use when writing tests or fixing linting issues.

日本語の概要は準備中です。原文の説明を表示しています。

実行スコア 未検証

インストール方法を見る

含まれるファイル(1)

  • SKILL.md7.9 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

Testing & Quality

Technologies: Jest, React Testing Library, Supertest, ESLint

Required Knowledge

  • Jest test framework
  • React Testing Library patterns
  • API testing with Supertest
  • In-memory database testing (MongoDB Memory Server, pg-mem)
  • ESLint configuration
  • Test-driven development

Relevant Documentation

DocumentTopics Covered
docs/development/LINTING.mdESLint setup, auto-fix, IDE integration
docs/development/BACKEND.mdBackend testing patterns
docs/development/FRONTEND.mdFrontend testing patterns

Testing Commands

# Unit tests (in-memory DBs — no services needed, default)
cd backend && npm test
cd backend && npm run test:coverage
./dev.sh test                        # same, runs inside Docker container

# Integration tests (real Docker Compose services)
./dev.sh up                          # start mongo + postgres first
./dev.sh test:integration            # INTEGRATION_TEST=true npm test --forceExit
# or manually:
INTEGRATION_TEST=true npm --prefix backend test -- --forceExit

# Frontend tests
cd frontend && npm test
cd frontend && npm run test:coverage

# Linting
npm run lint
npm run lint:fix

INTEGRATION_TEST env var

backend/__tests__/setup.js switches between two modes:

  • INTEGRATION_TEST not set (default): sets PG_HOST=undefined and MONGO_URI=undefined → triggers in-memory MongoDB Memory Server + pg-mem
  • INTEGRATION_TEST=true: connects to real services:
    • MongoDB: localhost:27017 (db: commonly-test)
    • PostgreSQL: localhost:5432 (db: commonly-test, user: postgres, no SSL)
    • Requires ./dev.sh up to be running first

Override connection strings via env vars: MONGO_URI, PG_HOST, PG_PORT, PG_DATABASE, PG_USER, PG_PASSWORD.

High-value Current Test Areas

E2E Integration Tests

  • Two-Way Integration E2E: backend/__tests__/service/two-way-integration-e2e.test.js (23 tests)
    • Inbound flow: External platforms (GroupMe, Discord) → Commonly via ingest endpoint
    • Scheduler summarization: Buffer processing and agent event queuing
    • Agent posting: commonly-bot posting summaries to pods via runtime API
    • Outbound flow: Commonly → Discord webhooks / GroupMe bot API
    • Full round-trip: External → Commonly → External
    • Multi-agent: Clawdbot, custom agents, agent chaining
  • Integrations E2E: backend/__tests__/service/integrations-e2e.test.js
  • Clawdbot E2E: backend/__tests__/service/clawdbot-e2e.test.js

Contract and Unit Tests

  • Integration provider contract tests: backend/__tests__/contracts/integrationProvider.contract.test.js.
  • Integration catalog + manifest validation routes.
  • backend/__tests__/unit/routes/integrations.catalog.test.js.
  • backend/__tests__/unit/routes/integrations.validation.test.js.
  • Pod context and skill synthesis.
  • backend/__tests__/unit/routes/pods.context.test.js.
  • backend/__tests__/unit/services/podContextService.test.js.
  • backend/__tests__/unit/services/podSkillService.test.js.

Backend Testing Patterns

Unit Test

describe('MessageService', () => {
  it('should create a message', async () => {
    const message = await MessageService.create({
      podId: 'pod123',
      userId: 'user123',
      content: 'Hello'
    });
    expect(message.content).toBe('Hello');
  });
});

API Test

describe('POST /api/messages', () => {
  it('should create message', async () => {
    const res = await request(app)
      .post('/api/messages')
      .set('Authorization', `Bearer ${token}`)
      .send({ podId: 'pod123', content: 'Hello' });
    expect(res.status).toBe(201);
  });
});

Frontend Testing Patterns

Component Test

describe('ChatRoom', () => {
  it('renders messages', async () => {
    render(<ChatRoom podId="123" />);
    await waitFor(() => {
      expect(screen.getByText('Hello')).toBeInTheDocument();
    });
  });
});

Mock Axios

jest.mock('axios');
axios.get.mockResolvedValue({ data: mockMessages });

E2E Integration Testing Patterns

Two-Way Integration Test Setup

// Mock summarizer to avoid Gemini API calls
jest.mock('../../services/summarizerService', () => ({
  generateSummary: jest.fn().mockResolvedValue('AI-generated summary.'),
  summarizePosts: jest.fn().mockResolvedValue({ title: 'Posts Summary', content: 'Summary' }),
  summarizeChats: jest.fn().mockResolvedValue({ title: 'Chats Summary', content: 'Summary' }),
}));

// Mock external APIs
jest.mock('axios');
global.fetch = jest.fn();

Ingest Token Creation Pattern

const { hash, randomSecret } = require('../../utils/secret');

const createIngestToken = async (integrationId) => {
  const token = `cm_int_${randomSecret(16)}`;
  const tokenHash = hash(token);
  await Integration.findByIdAndUpdate(integrationId, {
    $push: {
      ingestTokens: {
        tokenHash,
        label: 'Test Token',
        createdBy: testUser._id,
        createdAt: new Date(),
      },
    },
  });
  return token;
};

Agent Runtime Token Pattern

// Install agent
await request(app)
  .post('/api/registry/install')
  .set('Authorization', `Bearer ${authToken}`)
  .send({
    agentName: 'commonly-bot',
    podId: testPod._id.toString(),
    scopes: ['context:read', 'summaries:read', 'messages:write'],
  });

// Get runtime token
const tokenRes = await request(app)
  .post(`/api/registry/pods/${testPod._id}/agents/commonly-bot/runtime-tokens`)
  .set('Authorization', `Bearer ${authToken}`)
  .send({ label: 'Test Token' });

const runtimeToken = tokenRes.body.token;

// Post message as agent
await request(app)
  .post(`/api/agents/runtime/pods/${testPod._id}/messages`)
  .set('Authorization', `Bearer ${runtimeToken}`)
  .send({ content: 'Summary content', messageType: 'text' });

Multi-Agent Test Pattern

// Install multiple agents on same pod
await Promise.all([
  request(app).post('/api/registry/install').set('Authorization', `Bearer ${authToken}`)
    .send({ agentName: 'commonly-bot', podId: testPod._id.toString(), scopes: [...] }),
  request(app).post('/api/registry/install').set('Authorization', `Bearer ${authToken}`)
    .send({ agentName: 'clawdbot', podId: testPod._id.toString(), scopes: [...] }),
]);

// Enqueue events for each agent
await AgentEventService.enqueue({ agentName: 'commonly-bot', podId, type: 'discord.summary', payload: {...} });
await AgentEventService.enqueue({ agentName: 'clawdbot', podId, type: 'integration.summary', payload: {...} });

// Each agent polls their own events
const commonlyPoll = await request(app).get('/api/agents/runtime/events')
  .set('Authorization', `Bearer ${commonlyToken}`);
const clawdbotPoll = await request(app).get('/api/agents/runtime/events')
  .set('Authorization', `Bearer ${clawdbotToken}`);

ESLint Configuration

// .eslintrc.js
module.exports = {
  extends: ['eslint:recommended', 'plugin:react/recommended'],
  rules: {
    'no-unused-vars': 'error',
    'no-console': 'warn'
  }
};

Current Repo Notes (2026-02-08)

Skill catalog is generated into docs/skills/awesome-agent-skills-index.json. Gateway registry lives at /api/gateways with shared skill credentials at /api/skills/gateway-credentials (admin-only). Gateway credentials apply to all agents on the selected gateway; Skills page includes a Gateway Credentials tab. OpenClaw agent config can sync imported pod skills into workspace skills/ and writes HEARTBEAT.md per agent workspace. Social/activity route coverage now includes:

  • backend/__tests__/unit/routes/users.social.test.js (user follow/unfollow routes)
  • backend/__tests__/unit/routes/activity.read.test.js (unread count + mark-read routes)
  • backend/__tests__/unit/routes/posts.test.js extended for thread follow routes.

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

コメント

ログインなしで書き込めます。使ってみた感想、質問、動かなかった環境などを気軽にどうぞ。

まだコメントはありません。最初のコメントを書いてみませんか。

送信するとすぐに公開されます。メールアドレスや電話番号などの個人情報は書かないでください。URL は 2 つまでです。

0 / 1000 文字

このフォームは reCAPTCHA で保護されており、Google のプライバシーポリシーと利用規約が適用されます。

同じリポジトリのスキル

commonly

無料

You are a member of a Commonly workspace — a shared space where humans and AI agents from any origin collaborate in pods (chat rooms with memory). Use this whenever you are connected to Commonly via the commonly_* MCP tools: to read what's happening, post, remember things across sessions, react, DM other agents, and work the task board. Load it the moment you see any commonly_* tool available.

日本語の概要は準備中です。原文の説明を表示しています。

Team-Commonly/commonly1,3702026年10月25日 更新

commonly

無料

Use a Commonly pod as shared context for coding work, and post concise handoffs or files to teammates through its MCP tools. Load whenever commonly_* MCP tools are available.

日本語の概要は準備中です。原文の説明を表示しています。

Team-Commonly/commonly1,3702026年10月25日 更新

Use this skill for ANY visual / UI / design work on Commonly — picking colors, choosing fonts, styling new v2 components, building HTML mocks, designing marketing pages, or auditing whether a change matches the brand. Triggers on tasks involving v2.css tokens, accent / blue / focus ring / SF font, brand mark / logo, design system, design tokens, agent avatars / role tints, pod / chat / inspector / composer styling, marketing landing or login pages, screenshots / demo polish, "make this look better", "design this", "polish UI", "match the brand", "what's the right color/font/spacing/radius". Sources of truth live at `frontend/design-system/` (tokens.css, README.md, brand mark SVG, preview cards) and `frontend/src/v2/v2.css` (production tokens). Read both before recommending or shipping anything.

日本語の概要は準備中です。原文の説明を表示しています。

Team-Commonly/commonly1,3702026年10月25日 更新

github

無料

Interact with GitHub (issues, PRs, repos, releases) using the `gh` CLI. Use when asked to read or write GitHub state — open an issue, fetch PR diff, comment, list runs, etc.

日本語の概要は準備中です。原文の説明を表示しています。

Team-Commonly/commonly1,3702026年10月25日 更新

Convert binary documents (PDF, DOCX, XLSX, PPTX, HTML, EPUB, images) to clean LLM-friendly Markdown using Microsoft's `markitdown` Python tool. Use when a user attaches a binary file and you need to read its contents.

日本語の概要は準備中です。原文の説明を表示しています。

Team-Commonly/commonly1,3702026年10月25日 更新

morph-ppt

無料

Use this skill when the user wants a .pptx with smooth cross-slide animation — PowerPoint Morph transitions, Keynote-style continuous motion, shapes that grow / move / rotate as the slide advances. Trigger on: 'morph', 'morph transition', 'smooth transition', 'continuous animation across slides', 'Keynote-style transition', 'animated slide sequence', 'shape continuity across slides'. Output is a single .pptx. This skill is a scene layer on top of officecli-pptx — inherits every pptx v2 rule (visual floor, grid, palettes, connector canon, Delivery Gate 1–5a). DO NOT invoke for a generic deck, pitch deck, or board review without cross-slide motion — route those to officecli-pptx base or officecli-pitch-deck.

日本語の概要は準備中です。原文の説明を表示しています。

Team-Commonly/commonly1,3702026年10月25日 更新

Team-Commonly のスキルをすべて見る

このスキルの問題を報告する