Token导航 LogoToken导航

Agent Skill · 研究检索

test-coverage(测试覆盖率)

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

test-coverage 是研究检索类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为需要联网;许可证信息还不明确,第三方扫描已通过,按安装量在研究检索类的 73,675 个 Skill 里排第 32,923。

总安装 2,446周安装 104GitHub Stars 4下载 857核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

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

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

命令行安装

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

skills.shnpx skills
npx skills add https://github.com/cognitedata/dune-skills --skill test-coverage

这个 Skill 是做什么的

研究检索类 Skill 主要解决「找资料、核对事实、把来源整理清楚」的问题,通常会让助手先检索再总结。

用于辅助测试设计、自动化测试、用例整理和回归验证。适合编写单元测试、端到端测试或根据失败日志定位问题。需确认项目测试框架、运行命令和夹具数据后使用。适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。涉及浏览器或外部服务时应区分本地模拟与生产环境。

test-coverage 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

来源仓库内路径:skills/test-coverage

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/cognitedata/dune-skills --skill test-coverage;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要需要联网,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

test-coverage 怎么安装?

在终端执行 npx skills add https://github.com/cognitedata/dune-skills --skill test-coverage。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

test-coverage 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

test-coverage 需要什么权限?

权限级别是需要联网。该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

test-coverage 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

test-coverage 用的人多吗?

公开数据是累计安装 2,446 次,近一周安装 104 次,下载 857 次,GitHub 4 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

test-coverage 安全吗?

第三方扫描结果为通过,但这只覆盖已知的静态检查项,不能替代自己读一遍源码和安装命令。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 第三方扫描已通过,常见的高风险行为没有命中。

先想清楚的地方

  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理研究检索类任务、又不想每次都手写提示词的人。

不太适合

  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

研究检索类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
find-skills

寻找技能 · Codex、Claude

31,199,81316,486操作浏览器MIT有提醒
self-improving-agent

自我改进 Agent · OpenClaw

16,464,0023,396接触敏感数据MIT-0通过
soultrace

灵魂追踪 · Codex、Claude

7,588,94412需要联网未明确有提醒
self-improving

自我完善 · OpenClaw

6,829,2841,046需要联网MIT-0通过
microsoft-foundry

微软代工厂 · Codex、Claude

6,614,144764调用外部服务未明确有提醒
test-coverage

测试覆盖率 · 本页

2,4464需要联网未明确通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

Test Coverage Fix

Fix test coverage for $ARGUMENTS (or the whole app if no argument is given). This skill enforces the 80% line coverage hard gate required for Dune app approval by finding AND fixing coverage gaps. Work through every step in order.


Step 1 — Verify test framework and coverage tooling

Check that the project has a working test framework with coverage configured:

# Check for vitest or jest in package.json
grep -E "(vitest|jest)" package.json

# Check for coverage configuration
cat vitest.config.ts 2>/dev/null || cat vitest.config.js 2>/dev/null || cat jest.config.ts 2>/dev/null || cat jest.config.js 2>/dev/null

Verify:

  • A test framework (Vitest or Jest) is installed and configured
  • The config file has a coverage section (e.g. coverage: {provider: 'v8',...} in vitest.config.ts)
  • A coverage reporter is configured (at least text and lcov or json-summary)

If coverage tooling is not configured, fix it now:

  1. Install the coverage provider:
pnpm add -D @vitest/coverage-v8
  1. Add the coverage configuration to vitest.config.ts. Read the existing config file, then add the coverage section inside test:
// vitest.config.ts — minimum coverage configuration to add
test: {
  coverage: {
    provider: 'v8',
    reporter: ['text', 'text-summary', 'lcov'],
    include: ['src/**/*.{ts,tsx}'],
    exclude: [
      'src/**/*.test.{ts,tsx}',
      'src/**/*.spec.{ts,tsx}',
      'src/**/vite-env.d.ts',
      'src/main.tsx',
    ],
  },
}

Write the updated config file. If no vitest.config.ts exists at all, create one with the full defineConfig wrapper.


Step 2 — Validate coverage scope

The 80% threshold applies to all .ts and .tsx files under src/, excluding only:

  • Test files (*.test.ts, *.test.tsx, *.spec.ts, *.spec.tsx)
  • Type declaration files (vite-env.d.ts)
  • The entry point (main.tsx)

Apps must not exclude pages, components, hooks, or other production code from coverage measurement.

# Check what files are excluded from coverage in the config
grep -A 20 "exclude" vitest.config.ts 2>/dev/null || grep -A 20 "exclude" vitest.config.js 2>/dev/null

# Check for coveragePathIgnorePatterns in jest config
grep -A 10 "coveragePathIgnorePatterns\|collectCoverageFrom" jest.config.ts 2>/dev/null

If the config excludes production files, fix it now:

Remove any exclusion that hides production code from coverage measurement. Only test files, type declarations, and the entry point should be excluded. Rewrite the exclude array to contain only:

exclude: [
  'src/**/*.test.{ts,tsx}',
  'src/**/*.spec.{ts,tsx}',
  'src/**/vite-env.d.ts',
  'src/main.tsx',
],

Specifically remove any exclusions for:

  • src/pages/ or src/components/ or src/hooks/ — NOT allowed
  • Specific feature files — NOT allowed unless they are generated code
  • src/**/*.tsx (all components) — NOT allowed, this hides the majority of the app

Write the corrected config file.


Step 3 — Run tests and collect coverage

# Try common coverage commands based on project setup
npx vitest run --coverage 2>/dev/null || npx jest --coverage 2>/dev/null || npm test -- --coverage 2>/dev/null

Record the coverage summary:

  • Statements: X%
  • Branches: X%
  • Functions: X%
  • Lines: X%

Hard gate: Overall line coverage must be at least 80%. Apps below this threshold are listed as must fix.

If tests fail to run, fix them now:

Common fixes:

  • Missing imports: Read the failing test file, add the missing import statement, write the fixed file.
  • Broken mocks: Read the test to understand what is being mocked. Fix the mock to match the current API of the mocked module.
  • Outdated snapshots: Run npx vitest run --update to update snapshots, then review the diff to ensure correctness.
  • Missing dependencies: Run pnpm add -D <missing-package> for any test utilities not yet installed.
  • Config errors: Read the config file, fix syntax or option errors, write the corrected file.

Re-run tests after each fix until all tests pass. Then record the coverage summary.


Step 4 — Find and write missing test files

For every non-trivial .ts/.tsx file under src/, check whether a corresponding test file exists:

# List all production files and check for test counterparts
for file in $(find src -name "*.ts" -o -name "*.tsx" | grep -v ".test." | grep -v ".spec." | grep -v "node_modules" | grep -v "vite-env" | sort); do
  base="${file%.*}"
  ext="${file##*.}"
  dir=$(dirname "$file")
  filename=$(basename "$base")

  # Check for test file in same directory or __tests__ directory
  test_exists="false"
  for pattern in "${base}.test.${ext}" "${base}.spec.${ext}" "${base}.test.ts" "${base}.spec.ts" "${dir}/__tests__/${filename}.test.${ext}" "${dir}/__tests__/${filename}.spec.${ext}"; do
    if [ -f "$pattern" ]; then
      test_exists="true"
      break
    fi
  done

  if [ "$test_exists" = "false" ]; then
    echo "NO TEST: $file"
  fi
done

Categorize each file without a test:

  • Services, hooks, utils, contexts, ViewModel hooks — Write the test file now (see below)
  • Pure presentational components with no logic — Mark as N/A (no test required)
  • Barrel exports (index.ts that only re-exports) — Mark as N/A
  • Type-only files (.d.ts, files with only type/interface exports) — Mark as N/A

For each file missing a test, create a comprehensive test file. Use context injection for dependency mocking where the production code supports it. If the production code uses hard-coded imports, note this as a testability concern but still write the test using vi.mock with a justification comment. Follow this process for each:

  1. Read the source file to understand its exports, dependencies, and logic.
  2. Create a .test.ts or .test.tsx file in the same directory as the source file.
  3. Write tests covering: happy path, error path, empty state, and edge cases.

Use the right testing pattern for each file type:

For hooks:

  • Test with renderHook from @testing-library/react
  • Wrap with necessary providers (QueryClientProvider, custom context providers, etc.)
  • Test initial state, loading state, success state, and error state
  • Example structure:
import { renderHook, waitFor } from '@testing-library/react';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
// import the hook

const createWrapper = () => {
  const queryClient = new QueryClient({
    defaultOptions: { queries: { retry: false } },
  });
  return ({ children }: { children: React.ReactNode }) => (
    <QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
  );
};

describe('useMyHook', () => {
  it('returns data on success', async () => {
    const { result } = renderHook(() => useMyHook(), { wrapper: createWrapper() });
    await waitFor(() => expect(result.current.data).toBeDefined());
  });

  it('handles errors', async () => {
    // set up error condition
    const { result } = renderHook(() => useMyHook(), { wrapper: createWrapper() });
    await waitFor(() => expect(result.current.error).toBeDefined());
  });
});

For services/utils:

  • Test with direct function calls
  • Mock CDF SDK responses where needed
  • Test return values, side effects, and thrown errors
  • Example structure:
import { describe, it, expect, vi } from 'vitest';
// import the service/util functions

describe('myService', () => {
  it('returns expected result for valid input', () => {
    const result = myFunction(validInput);
    expect(result).toEqual(expectedOutput);
  });

  it('throws on invalid input', () => {
    expect(() => myFunction(invalidInput)).toThrow();
  });
});

For components with logic:

  • Test with render from @testing-library/react
  • Verify loading, error, and data states
  • Test user interactions that trigger state changes
  • Example structure:
import { render, screen, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
// import the component and providers

describe('MyComponent', () => {
  it('shows loading state initially', () => {
    render(<MyComponent />, { wrapper: createWrapper() });
    expect(screen.getByText(/loading/i)).toBeInTheDocument();
  });

  it('renders data after loading', async () => {
    render(<MyComponent />, { wrapper: createWrapper() });
    await waitFor(() => {
      expect(screen.getByText('expected content')).toBeInTheDocument();
    });
  });
});

Dependency mocking guidelines:

  • Use context injection (not vi.mock) where possible — provide test dependencies via the hook's context.
  • If the production code uses hard-coded imports that prevent context injection, use vi.mock with a justification comment explaining why (e.g., // vi.mock required: useDataSource uses direct import, not context injection).
  • Ensure mocks are type-safe — no as unknown as T casts. Define proper mock objects that satisfy the interface.

After writing each test file, run npx vitest run <test-file> to verify it passes.


Step 5 — Fix low-coverage files

If the coverage tool produces per-file metrics, list files below 80% line coverage:

# Parse lcov or text output for per-file coverage
cat coverage/coverage-summary.json 2>/dev/null | node -e "
  const data = JSON.parse(require('fs').readFileSync('/dev/stdin','utf8'));
  Object.entries(data).forEach(([file, metrics]) => {
    if (file === 'total') return;
    const pct = metrics.lines?.pct ?? 0;
    if (pct < 80) console.log(pct.toFixed(1) + '% — ' + file);
  });
" 2>/dev/null

For each file below 80% coverage, read the uncovered lines from the coverage report, then add test cases that exercise those specific code paths:

  1. Read the uncovered lines from the coverage report. Check the coverage/ directory for detailed per-file reports (lcov or html) that show which lines are uncovered.
  2. Read the source file to understand what those uncovered lines do.
  3. Add test cases that exercise those specific code paths:
  • Uncovered error paths: Add tests that trigger error conditions (network failures, invalid input, null values, permission errors). Force errors by providing bad input or mocking dependencies to throw.
  • Uncovered branches: Add tests for each conditional branch. If an if/else has only the true branch tested, write a test that triggers the false branch.
  • Uncovered functions: Add tests that call each exported function that lacks coverage. Verify return values and side effects.
  • Uncovered catch blocks: Mock the upstream call to reject/throw, verify the catch block behavior.
  1. Run coverage again after adding tests to verify the file now meets 80%:
npx vitest run --coverage <test-file>

Repeat until each file reaches at least 80% line coverage or you have covered all feasible paths.


Step 6 — Fix testability patterns

Assess and fix testability issues in the codebase:

# Check for dependency injection via context
grep -rn --include="*.ts" --include="*.tsx" "useContext\|createContext" src/hooks/ src/contexts/

# Check for vi.mock usage (red flag for testability)
grep -rn --include="*.ts" --include="*.tsx" "vi\.mock" src/

# Check for unsafe casts in tests
grep -rn --include="*.ts" --include="*.tsx" "as unknown as" src/ | grep -E "\.test\.|\.spec\."

# Check for interface-based services
grep -rn --include="*.ts" --include="*.tsx" -E "implements\s+\w+" src/

For each testability issue found, refactor the production code to support better testing patterns. Then update the corresponding test to use the improved pattern.

IssueFix
Hook imports dependencies directly instead of using contextAdd a context type with default dependencies. Create a context with createContext, provide defaults that use the real implementation. In the hook, use useContext to get dependencies. Tests can then provide mock dependencies via the context provider without vi.mock.
Service has no interfaceExtract a TypeScript interface describing the service's public API. Have the class/object implement the interface. Tests mock against the interface, not the concrete implementation.
Page component mixes data fetching with renderingExtract data logic into a use*ViewModel hook. The page component calls the ViewModel hook and renders based on its return value. Test the ViewModel hook separately with renderHook, test the page component with a mocked ViewModel.
Tests use vi.mock for modules that could use context injectionAfter refactoring the production code to use context injection (above), update the test to provide mock dependencies via the context provider. Remove the vi.mock call. Add a comment explaining the pattern.
Tests use as unknown as T casts for mocksDefine a proper mock type or object that satisfies the required interface. Replace the cast with a properly typed mock. If the interface is large, create a helper function that returns a partial mock with only the methods used, typed correctly.

For each refactored file:

  1. Read the source file and its test file.
  2. Refactor the production code (add context, extract interface, extract ViewModel hook).
  3. Update the test to use the improved pattern.
  4. Run npx vitest run <test-file> to verify the test still passes.

Step 7 — Report remaining gaps

Re-run the full test suite with coverage to get final numbers:

npx vitest run --coverage 2>/dev/null || npx jest --coverage 2>/dev/null

Produce a summary of what was done and what remains:

### Test Coverage Summary (After Fixes)

| Metric | Before | After | Gate |
|--------|--------|-------|------|
| Lines | X% | Y% | ≥80% required |
| Branches | X% | Y% | — |
| Functions | X% | Y% | — |
| Statements | X% | Y% | — |

### Coverage verdict: PASS / FAIL

### What was fixed
- [ ] Coverage tooling configured/corrected
- [ ] Exclusions cleaned up (removed N production file exclusions)
- [ ] N failing tests fixed
- [ ] N new test files written (list them)
- [ ] N existing test files expanded for coverage
- [ ] N files refactored for testability

### Remaining gaps (needs human review)
Only list issues that could not be auto-fixed:
- Complex business logic where correct test assertions require domain knowledge
- Integration tests that need real API credentials or environment setup
- Files where coverage cannot reach 80% without major architectural changes (explain why)

Done

Summarize:

  • Overall coverage before and after fixes, vs the 80% gate (PASS or FAIL)
  • Number of test files written and tests added
  • Number of files refactored for testability
  • Any remaining must fix items that need human review

适合场景

01

研究助手

02

事实核查

03

知识库问答

04

带来源的搜索总结

能力概览

能力 1

组合搜索和大模型调用

能力 2

支持多来源检索和总结

能力 3

强调引用来源和事实核查

能力 4

适合研究型 Agent 流程

平台分布

Codex

36.02%
按下载量换算309

Claude

33.46%
按下载量换算287

Cursor

17.56%
按下载量换算150

Gemini CLI

9.95%
按下载量换算85

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

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

继续浏览同类 Skills