Identify test anti-patterns and improve tests without polluting production code.
The material indicates an open-source, prompt/document-style testing skill with no required secrets, no remote endpoints, and no declared execution or data access capabilities, so overall risk is low. The main uncertainty is low community adoption and unknown maintenance status, but no concrete high-risk red flags are evident from the provided facts.
The material explicitly states that no keys or environment variables are required; as a prompt/document-style skill, there is no visible path for credential collection, storage, or misuse.
No remote endpoints or network activity are declared; based on the provided content, it does not appear to send user data to external services.
The system flags it as prompt-only, and the README contains only testing anti-pattern guidance and sample code; it does not show any ability to spawn processes, run scripts, or invoke system capabilities.
The material does not describe any file I/O, local directory access, or read/write scope over external resources; factually it appears to provide only textual development guidance.
It is marked as open source and hosted on GitHub, making the source auditable, which materially lowers risk; however, the repository has 0 stars, no declared license, and unknown maintenance status, so source maturity and ongoing maintenance warrant attention.
Copy the install command and let the AI configure it · recommended for beginners
Please install the "testing-anti-patterns" skill from askskill: 1. Download https://raw.githubusercontent.com/microsoft/FluidFramework/main/.agency/plugins/nori/skills/testing-anti-patterns/SKILL.md 2. Save it as ~/.claude/skills/testing-anti-patterns/SKILL.md 3. Reload skills and tell me it's ready
Please review these unit test changes and identify anti-patterns: whether the tests verify mock behavior, whether production code was given test-only methods, and whether dependencies are over-mocked without understanding them. Then suggest better refactoring approaches.
A review highlighting specific anti-patterns, their risks, and refactoring suggestions for more behavior-focused tests.
I’m about to add several mocks to this test. First analyze the real dependencies of the unit under test, decide which dependencies should remain real and which can be replaced with test doubles, and explain how to avoid turning the test into mock-interaction verification only.
A dependency analysis and mock usage recommendation that reduces unnecessary doubles and improves test effectiveness.
I want to add a test-only method to production code for easier testing. Please assess whether this is an anti-pattern and propose alternative testing strategies that avoid changing the public API or adding test-specific methods.
An explanation of the problem and alternatives such as structural refactoring, dependency injection, or higher-level tests.
Tests must verify real behavior, not mock behavior. Mocks are a means to isolate, not the thing being tested.
Core principle: Test what the code does, not what the mocks do.
Following strict TDD prevents these anti-patterns.
1. NEVER test mock behavior
2. NEVER add test-only methods to production classes
3. NEVER mock without understanding dependencies
The violation:
// ❌ BAD: Testing that the mock exists
test('renders sidebar', () => {
render(<Page />);
expect(screen.getByTestId('sidebar-mock')).toBeInTheDocument();
});
Why this is wrong:
your human partner's correction: "Are we testing the behavior of a mock?"
The fix:
// ✅ GOOD: Test real component or don't mock it
test('renders sidebar', () => {
render(<Page />); // Don't mock sidebar
expect(screen.getByRole('navigation')).toBeInTheDocument();
});
// OR if sidebar must be mocked for isolation:
// Don't assert on the mock - test Page's behavior with sidebar present
BEFORE asserting on any mock element:
Ask: "Am I testing real component behavior or just mock existence?"
IF testing mock existence:
STOP - Delete the assertion or unmock the component
Test real behavior instead
The violation:
// ❌ BAD: destroy() only used in tests
class Session {
async destroy() {
// Looks like production API!
await this._workspaceManager?.destroyWorkspace(this.id);
// ... cleanup
}
}
// In tests
afterEach(() => session.destroy());
Why this is wrong:
The fix:
// ✅ GOOD: Test utilities handle test cleanup
// Session has no destroy() - it's stateless in production
// In test-utils/
export async function cleanupSession(session: Session) {
const workspace = session.getWorkspaceInfo();
if (workspace) {
await workspaceManager.destroyWorkspace(workspace.id);
}
}
// In tests
afterEach(() => cleanupSession(session));
BEFORE adding any method to production class:
Ask: "Is this only used by tests?"
IF yes:
STOP - Don't add it
Put it in test utilities instead
Ask: "Does this class own this resource's lifecycle?"
IF no:
STOP - Wrong class for this method
The violation:
// ❌ BAD: Mock breaks test logic
test('detects duplicate server', () => {
// Mock prevents config write that test depends on!
vi.mock('ToolCatalog', () => ({
discoverAndCacheTools: vi.fn().mockResolvedValue(undefined),
}));
await addServer(config);
await addServer(config); // Should throw - but won't!
});
Why this is wrong:
The fix:
// ✅ GOOD: Mock at correct level
test('detects duplicate server', () => {
// Mock the slow part, preserve behavior test needs
vi.mock('MCPServerManager'); // Just mock slow server startup
await addServer(config); // Config written
await addServer(config); // Duplicate detected ✓
});
BEFORE mocking any method:
STOP - Don't mock yet
1. Ask: "What side effects does the real method have?"
2. Ask: "Does this test depend on any of those side effects?"
3. Ask: "Do I fully understand what this test needs?"
IF depends on side effects:
…
Generate Fluid-style PR content, push branches, and open GitHub pull requests.
Explains how to use abilities effectively before starting any conversation.
Break large, long-running tasks into manageable chunks and preserve context.
Turn rough ideas into actionable designs through structured questioning and validation.
Draft and review Fluid Framework PR titles and descriptions consistently.
Update technical documentation after code changes are completed.
Helps developers avoid common testing anti-patterns and write more reliable tests.
Write behavior-focused, refactor-resistant tests that verify intent and regressions.
Write failing tests first to implement features and bug fixes reliably.
Implement features and fixes by writing tests before production code.
Design test strategies and plans with coverage, methods, and quality priorities.
Use test-first development to improve code quality and maintainability.