Enforce testing best practices - AAA pattern, naming conventions, isolation, coverage thresholds. Blocks non-compliant tests. Use when writing or reviewing tests.
View on GitHubyonatangross/skillforge-claude-plugin
ork
January 25, 2026
Select agents to install to:
npx add-skill https://github.com/yonatangross/skillforge-claude-plugin/blob/main/skills/test-standards-enforcer/SKILL.md -a claude-code --skill test-standards-enforcerInstallation paths:
.claude/skills/test-standards-enforcer/Enforce 2026 testing best practices with **BLOCKING** validation.
## Validation Rules
### BLOCKING Rules (exit 1)
| Rule | Check | Example Violation |
|------|-------|-------------------|
| **Test Location** | Tests must be in `tests/` or `__tests__/` | `src/utils/helper.test.ts` |
| **AAA Pattern** | Tests must have Arrange/Act/Assert structure | No clear sections |
| **Descriptive Names** | Test names must describe behavior | `test('test1')` |
| **No Shared State** | Tests must not share mutable state | `let globalVar = []` without reset |
| **Coverage Threshold** | Coverage must be ≥ 80% | 75% coverage |
### File Location Rules
```
ALLOWED:
tests/unit/user.test.ts
tests/integration/api.test.ts
__tests__/components/Button.test.tsx
app/tests/test_users.py
tests/conftest.py
BLOCKED:
src/utils/helper.test.ts # Tests in src/
components/Button.test.tsx # Tests outside test dir
app/routers/test_routes.py # Tests mixed with source
```
### Naming Conventions
**TypeScript/JavaScript:**
```typescript
// GOOD - Descriptive, behavior-focused
test('should return empty array when no items exist', () => {})
test('throws ValidationError when email is invalid', () => {})
it('renders loading spinner while fetching', () => {})
// BLOCKED - Too short, not descriptive
test('test1', () => {})
test('works', () => {})
it('test', () => {})
```
**Python:**
```python
# GOOD - snake_case, descriptive
def test_should_return_user_when_id_exists():
def test_raises_not_found_when_user_missing():
# BLOCKED - Not descriptive, wrong case
def testUser(): # camelCase
def test_1(): # Not descriptive
```
## AAA Pattern (Required)
Every test must follow Arrange-Act-Assert:
### TypeScript Example
```typescript
describe('calculateDiscount', () => {
test('should apply 10% discount for orders over $100', () => {
// Arrange
const order = createOrder({ total: 150 });
const calculator = new DiscountCalculator();
// Act
const discount