Agent Skills
› NeverSight/learn-skills.dev
› testing-operations
testing-operations
GitHub用于3Lens项目的测试操作技能,涵盖合约合规性测试、回归测试及覆盖率验证。支持编写测试用例、从追踪数据创建回归套件、调试失败及理解测试模式,确保系统行为符合预期且性能达标。
Trigger Scenarios
编写合约合规性测试
创建回归测试套件
验证测试覆盖率
调试测试失败
理解测试模式
Install
npx skills add NeverSight/learn-skills.dev --skill testing-operations -g -y
SKILL.md
Frontmatter
{
"name": "testing-operations",
"description": "Contract and regression testing workflows. Use when writing tests, validating contract compliance, or creating regression test suites."
}
Testing Operations
Testing operations cover writing contract compliance tests, regression tests, and validating test coverage for 3Lens.
When to Use
- Writing contract compliance tests
- Creating regression tests from traces
- Validating test coverage
- Debugging test failures
- Understanding test patterns
Test Types
Contract Compliance Tests
Tests that validate contract invariants:
// tests/contracts/inspector.test.ts
import { describe, it, expect } from 'vitest';
import { createLens } from '@3lens/runtime';
describe('Inspector Contract', () => {
it('answers the 5 questions for any entity', async () => {
const lens = createLens();
const entityId = 'mesh:main:myMesh';
// Question 1: What is this?
const info = await lens.inspect(entityId, { include: ['info'] });
expect(info).toBeDefined();
// Question 2: Dependencies?
const deps = await lens.inspect(entityId, { include: ['dependencies'] });
expect(deps.dependencies).toBeArray();
// Question 3: What depends on it?
const dependents = await lens.inspect(entityId, { include: ['dependents'] });
expect(dependents.dependents).toBeArray();
// Question 4: Cost?
const cost = await lens.inspect(entityId, { include: ['cost'] });
expect(cost.cost).toHaveProperty('attribution');
// Question 5: How has it changed?
const diffs = await lens.inspect(entityId, { include: ['diffs'] });
expect(diffs.diffs).toBeArray();
});
});
Regression Tests
Tests that detect regressions:
// tests/regression/baseline.test.ts
import { describe, it, expect } from 'vitest';
import { loadTrace } from '@3lens/kernel';
describe('Regression: Baseline Performance', () => {
it('maintains frame time budget', async () => {
const trace = await loadTrace('./traces/baseline.json');
const frames = trace.getFrames();
const avgFrameTime = frames.reduce((sum, f) => sum + f.duration, 0) / frames.length;
expect(avgFrameTime).toBeLessThan(16.67); // 60fps budget
});
it('maintains memory budget', async () => {
const trace = await loadTrace('./traces/baseline.json');
const peakMemory = trace.getPeakMemory();
expect(peakMemory).toBeLessThan(100 * 1024 * 1024); // 100MB budget
});
});
Snapshot Tests
Tests for stable outputs:
// tests/snapshots/entity-graph.test.ts
import { describe, it, expect } from 'vitest';
import { createEntityGraph } from '@3lens/kernel';
describe('Entity Graph Snapshots', () => {
it('generates consistent graph structure', () => {
const graph = createEntityGraph();
// ... build graph
expect(graph.snapshot()).toMatchSnapshot();
});
});
Commands
Run Contract Tests
# Run all contract tests
3lens test contracts
# Test specific contract
3lens test contracts --contract inspector
# Show coverage
3lens test contracts --coverage
# Watch mode
3lens test contracts --watch
Generate Regression Tests
# Generate regression test from trace
3lens test:generate-regression baseline.json --out tests/regression/baseline.test.ts
Check Test Coverage
# Check contract test coverage
3lens test:coverage contracts
Test Patterns
Fidelity Testing
it('labels fidelity for all metrics', async () => {
const result = await client.query('top_hotspots');
result.items.forEach(item => {
expect(item).toHaveProperty('fidelity');
expect(['EXACT', 'ESTIMATED', 'UNAVAILABLE']).toContain(item.fidelity);
});
});
Attribution Testing
it('provides attribution path for metrics', async () => {
const metric = await client.query('top_hotspots');
expect(metric.attribution).toBeArray();
expect(metric.attribution.length).toBeGreaterThan(0);
expect(metric.attribution[0]).toHaveProperty('entityId');
expect(metric.attribution[0]).toHaveProperty('weight');
});
Live/Offline Parity Testing
describe('Live and Offline Parity', () => {
it('works in live mode', async () => {
const lens = createLens();
// Test live mode
});
it('works with offline traces', async () => {
const trace = await loadTrace('./traces/test.json');
// Test offline mode
});
});
Agent Use Cases
- New feature: "Generate tests for my new panel"
- Contract compliance: "Write tests for the inspector contract"
- Regression: "Create regression test from this trace"
- Coverage: "Check test coverage for contracts"
Test Requirements
Every test MUST:
-
Validate Contract Invariants
- Test all contract requirements
- Include degradation scenarios
-
Include Fidelity Checks
- Verify fidelity labeling
- Test fidelity propagation
-
Include Attribution Checks
- Verify attribution paths
- Test attribution weights
-
Test Live/Offline Parity
- Test both modes
- Verify consistent results
Post-Scaffold Steps
After writing tests, follow the playbook:
Additional Resources
- Contract: .cursor/contracts/testing.md (if exists)
- Rule: .cursor/rules/test-standards.mdc
- Use
vitestfor tests; validate-contracts for contract validation - Subagent: .cursor/agents/test-generator.md
Version History
- e0220ca Current 2026-07-05 23:30


