Token导航 LogoToken导航TokenDH.com
研究检索操作浏览器github未标认证来源可访问许可证需确认审计通过

testabilitytestability 搜索

Agent Skill

用于辅助测试设计、自动化测试、用例整理和回归验证。它适合让 Agent 编写单元测试、端到端测试、测试计划或根据失败日志定位问题。使用时需要确认项目测试框架、运行命令和夹具数据,避免为了通过测试而改坏真实逻辑;涉及浏览器或外部服务时,应区分本地模拟、测试环境和生产环境。

总安装

196

周安装

8

GitHub Stars

219

下载量

63
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:testability(testability 搜索)
来源仓库:https://github.com/different-ai/agent-bank
仓库路径:skills/testability
安装命令:
npx skills add https://github.com/different-ai/agent-bank --skill testability
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/different-ai/agent-bank --skill testability

简介

用于搜索和分析软件可测性相关的最佳实践与工具。

  • 适合查找测试框架推荐、mock 策略或覆盖率提升方法。
  • 使用时应结合项目技术栈筛选适用方案。
  • 避免盲目采用高侵入性手段,平衡可测性与开发效率。
  • 安装方式:通过 GitHub 仓库安装,支持 Codex、Claude、Cursor、Gemini CLI。

SKILL.md

What I Do

Ensure every feature you build is testable from the start. This skill teaches:

  1. Testing pyramid (fast → slow)
  2. API exposure patterns for testability
  3. Local testing setup
  4. Integration with staging tests
  5. When to use each testing layer

Core Philosophy

"If you can't test it locally, you can't test it."

Every feature should be testable at multiple levels. Design for testability, don't bolt it on later.


Testing Pyramid

From fastest (run constantly) to slowest (run occasionally):

                    ▲
                   /U\        UI Tests (E2E)
                  / I \       - Browser automation
                 /-----\      - Run on staging only
                / API   \     API/Integration Tests
               / TESTS   \    - tRPC procedures
              /-----------\   - Can run locally
             /   UNIT      \  Unit Tests
            /    TESTS      \ - Pure functions
           /------------------\ - Fastest, run always
LayerSpeedWhereWhen to Use
Unit<1sLocalPure logic, utils, calculations
API/Integration1-10sLocal + CItRPC, DB operations, business logic
Staging30s-2mVercel previewFull flow verification
UI/E2E2-5mStaging onlyCritical user journeys

Layer 1: Unit Tests (Fastest)

When to Use

  • Pure functions with no side effects
  • Calculations, formatting, validation
  • Business logic that doesn't touch DB/APIs

Pattern

// packages/web/src/lib/utils/calculate-fee.ts
export function calculateFee(amount: number, feePercent: number): number {
  return amount * (feePercent / 100);
}

// packages/web/src/lib/utils/calculate-fee.test.ts
import { describe, it, expect } from 'vitest';
import { calculateFee } from './calculate-fee';

describe('calculateFee', () => {
  it('calculates 1% fee correctly', () => {
    expect(calculateFee(1000, 1)).toBe(10);
  });

  it('handles zero amount', () => {
    expect(calculateFee(0, 5)).toBe(0);
  });
});

Running Unit Tests

cd packages/web
pnpm test                           # Run all tests (watch mode)
pnpm test -- --run                  # Run once and exit
pnpm test:watch                     # Watch mode
pnpm test -- --run --grep "fee"     # Filter by name
Repo note: @zero-finance/web Vitest discovers tests under packages/web/src/test/**/*.test.ts. Put new tests there (or update Vitest config) so they get picked up.

Layer 2: API/Integration Tests

When to Use

  • tRPC procedures
  • Database operations
  • External API integrations (mocked)
  • Business logic with dependencies

Pattern: Testing tRPC Procedures

// packages/web/src/server/routers/earn/get-balance.test.ts
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { createTestContext } from '@/test/context';
import { earnRouter } from './index';

describe('earn.getBalance', () => {
  let ctx: ReturnType<typeof createTestContext>;

  beforeEach(() => {
    ctx = createTestContext({
      user: { privyDid: 'test-user-did' },
      workspaceId: 'test-workspace-id',
    });
  });

  it('returns balance for valid user', async () => {
    const caller = earnRouter.createCaller(ctx);
    const result = await caller.getBalance({ chainId: 8453 });

    expect(result).toHaveProperty('balance');
    expect(typeof result.balance).toBe('string');
  });
});

Pattern: Mocking External Services

// Mock Privy
vi.mock('@privy-io/server-auth', () => ({
  PrivyClient: vi.fn().mockImplementation(() => ({
    getUser: vi.fn().mockResolvedValue({ id: 'test-user' }),
  })),
}));

// Mock Database
vi.mock('@/db', () => ({
  db: {
    query: {
      userSafes: {
        findFirst: vi.fn().mockResolvedValue({
          safeAddress: '0x1234...',
          chainId: 8453,
        }),
      },
    },
  },
}));

Test Database Setup

For tests that need a real database:

// packages/web/src/test/setup-db.ts
import { drizzle } from 'drizzle-orm/neon-http';
import { neon } from '@neondatabase/serverless';

export async function createTestDb() {
  // Use a test-specific database
  const sql = neon(process.env.TEST_DATABASE_URL!);
  return drizzle(sql);
}

Layer 3: Staging Tests (Vercel Preview)

When to Use

  • Full end-to-end flows
  • Features that involve multiple services
  • UI changes that need visual verification
  • Flows that can't be mocked locally

Workflow

# 1. Push your branch
git push -u origin feat/my-feature

# 2. Wait for deployment
LATEST=$(vercel ls --scope prologe 2>/dev/null | head -1)
vercel inspect "$LATEST" --scope prologe --wait --timeout 5m

# 3. Test on preview URL
# Use Chrome MCP or manual testing

Integration with test-staging-branch Skill

Load the test-staging-branch skill for:

  • Chrome automation login flow
  • Gmail OTP extraction
  • PR reporting
skill("test-staging-branch")

Layer 4: UI/E2E Tests (Slowest)

When to Use

  • Critical user journeys only
  • After all other layers pass
  • For regression prevention

Playwright Tests

// packages/web/tests/dashboard.spec.ts
import { test, expect } from '@playwright/test';

test('user can view dashboard balance', async ({ page }) => {
  // Login would use test fixtures
  await page.goto('/dashboard');

  await expect(page.getByText('Total Balance')).toBeVisible();
  await expect(page.getByTestId('balance-amount')).toBeVisible();
});

Running E2E Tests

cd packages/web
pnpm exec playwright test
pnpm exec playwright test --ui  # Interactive mode

Making Code Testable

Pattern 1: Dependency Injection

// BAD - Hard to test
export async function getBalance() {
  const safe = await db.query.userSafes.findFirst({...});
  const balance = await fetch(`https://api.example.com/balance/${safe.address}`);
  return balance;
}

// GOOD - Testable
export async function getBalance(
  deps: {
    getSafe: () => Promise<UserSafe>,
    fetchBalance: (address: string) => Promise<string>,
  }
) {
  const safe = await deps.getSafe();
  const balance = await deps.fetchBalance(safe.address);
  return balance;
}

Pattern 2: Extract Pure Functions

// BAD - Logic mixed with I/O
export async function processTransfer(amount: number) {
  const fee = amount * 0.01;
  const total = amount + fee;
  await db.insert(transfers).values({ amount, fee, total });
  return { amount, fee, total };
}

// GOOD - Pure function extractable
export function calculateTransferFees(amount: number) {
  const fee = amount * 0.01;
  const total = amount + fee;
  return { amount, fee, total };
}

export async function processTransfer(amount: number) {
  const calculated = calculateTransferFees(amount);
  await db.insert(transfers).values(calculated);
  return calculated;
}

// Now calculateTransferFees is easily unit testable!

Pattern 3: Test IDs in UI

// Add data-testid for E2E tests
<div data-testid="balance-card">
  <span data-testid="balance-amount">{balance}</span>
</div>

Pattern 4: API Routes for Testing

Expose internal state via API routes that are:

  • Only available in development/test
  • Protected in production
// packages/web/src/app/api/test/state/route.ts
import { NextResponse } from 'next/server';

export async function GET() {
  // Only in development
  if (process.env.NODE_ENV === 'production') {
    return NextResponse.json({ error: 'Not available' }, { status: 403 });
  }

  // Return internal state for testing
  return NextResponse.json({
    safesCount: await db.select().from(userSafes).count(),
    // ... other debug info
  });
}

Local Testing Setup

Environment Files

# .env.test - Test-specific config
DATABASE_URL="postgres://test:test@localhost:5432/test_db"
PRIVY_APP_ID="test-app-id"
# ... mocked values

Test Utilities

Create reusable test helpers:

// packages/web/src/test/fixtures.ts
export const testUser = {
  privyDid: 'did:privy:test-user',
  email: 'test@example.com',
};

export const testSafe = {
  address: '0x1234567890123456789012345678901234567890',
  chainId: 8453,
};

// packages/web/src/test/context.ts
export function createTestContext(overrides = {}) {
  return {
    user: testUser,
    workspaceId: 'test-workspace',
    db: mockDb,
    ...overrides,
  };
}

Testing Checklist (Per Feature)

Before considering a feature "done":

[ ] Unit tests for pure functions
[ ] Integration tests for tRPC procedures
[ ] Mocks for external services
[ ] Test IDs in UI components
[ ] Manual test on staging (if applicable)
[ ] E2E test for critical paths only

Common Anti-Patterns

Don't: Test implementation details

// BAD - Tests internal state
expect(component.state.isLoading).toBe(false);

// GOOD - Tests observable behavior
expect(screen.getByText('Loading...')).not.toBeVisible();

Don't: Over-mock

// BAD - Mock everything
vi.mock('@/db');
vi.mock('@/lib/api');
vi.mock('@/hooks/use-user');
// ... 10 more mocks

// GOOD - Mock only external boundaries
vi.mock('@/lib/external-api'); // Third-party only

Don't: Write E2E tests for everything

// BAD - E2E for simple validation
test('email validation shows error', async ({ page }) => {
  // This should be a unit test!
});

// GOOD - E2E for critical flows only
test('user can complete payment flow', async ({ page }) => {
  // Multi-step, multi-service flow
});

Integration with Other Skills

ScenarioSkill to Use
Testing fails on stagingtest-staging-branch
Need to debug prod datadebug prod issues
After completing testsskill-reinforcement
Need Chrome automationchrome-devtools-mcp

Learnings Log

Add new learnings here as they're discovered

2024-12-29: Initial skill created

  • Established testing pyramid hierarchy
  • Created patterns for dependency injection and pure function extraction
  • Added integration with other skills

2026-01-12: Next.js 16 async route params

  • Dynamic API routes now receive params as a Promise; await params before reading slug to avoid 404s in local CLI testing.

2026-01-12: Privy user provisioning defaults

  • Privy create-user rejects wallet_index and create_direct_signer; omit defaults and only send those fields when explicitly provided.

Quick Reference

# Unit tests
pnpm --filter @zero-finance/web test

# Watch mode
pnpm --filter @zero-finance/web test:watch

# E2E tests
pnpm --filter @zero-finance/web exec playwright test

# Type check (catches many bugs)
pnpm typecheck

# Lint
pnpm lint

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

39.77%
按下载量换算25

Claude

29.15%
按下载量换算18

Cursor

17.67%
按下载量换算11

Gemini CLI

10.02%
按下载量换算6

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

操作浏览器

该 Skill 可能涉及浏览器控制能力,使用时可能读取或操作网页内容,需要在受控环境中确认权限边界。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills