Test files present and organized
Why it matters
A codebase with no test files has no automated verification that the core logic works correctly after a change. Every refactor, dependency upgrade, or new feature becomes a manual regression risk. ISO 25010:2011 §6.5.5 identifies absence of test infrastructure as a reliability defect. For AI-built projects specifically, the lack of tests is a compounding risk: the original author may not remember the edge cases, and future changes can silently break behavior that was never encoded as an assertion.
Severity rationale
Medium because absent tests mean every change ships with no automated regression check, making regressions in business logic invisible until a user reports them.
Remediation
Set up a test framework appropriate for your stack. For Next.js/React with TypeScript, Vitest + Testing Library is the standard starting point.
npm install -D vitest @testing-library/react @testing-library/user-event jsdom
Add to package.json:
{
"scripts": {
"test": "vitest",
"test:coverage": "vitest run --coverage"
}
}
Create your first test co-located with the module it covers:
// src/lib/format-price.test.ts
import { describe, it, expect } from 'vitest'
import { formatPrice } from './format-price'
describe('formatPrice', () => {
it('formats a whole dollar amount', () => {
expect(formatPrice(1000)).toBe('$10.00')
})
it('returns "Free" for zero', () => {
expect(formatPrice(0)).toBe('Free')
})
})
Detection
-
ID:
test-files-present -
Severity:
medium -
What to look for: Search the project for test files using these patterns:
**/*.test.ts,**/*.test.tsx,**/*.spec.ts,**/*.spec.tsx,**/__tests__/**. Estimate the ratio of test files to source files — aim for at least 50% of business logic modules having a corresponding test. Check whether tests are co-located with source files (e.g.,utils/parse.tsandutils/parse.test.tsside-by-side) or collected in a__tests__directory. Examinepackage.jsonfor atestscript — its absence suggests testing is not part of the development workflow. Also check whether a test framework (jest, vitest, mocha) is present indevDependencies. -
Pass criteria: Test files are present covering at least 50% of business logic modules. A
testscript is defined inpackage.json. A test framework is indevDependencies. -
Fail criteria: No test files found anywhere in the project, or only placeholder/skeleton test files with no actual assertions.
-
Skip (N/A) when: Project is purely a static asset collection with no custom code logic (no JavaScript/TypeScript modules).
-
Detail on fail:
"No test files (*.test.ts, *.spec.ts, __tests__/) found; testing framework not configured in package.json" -
Remediation: Set up a test framework appropriate for your stack. For Next.js/React with TypeScript, Vitest or Jest with Testing Library is standard:
npm install -D vitest @testing-library/react @testing-library/user-event jsdomAdd to
package.json:{ "scripts": { "test": "vitest", "test:coverage": "vitest run --coverage" } }Create your first test alongside the module it covers:
// src/lib/format-price.test.ts import { describe, it, expect } from 'vitest' import { formatPrice } from './format-price' describe('formatPrice', () => { it('formats a whole dollar amount', () => { expect(formatPrice(1000)).toBe('$10.00') }) it('returns "Free" for zero', () => { expect(formatPrice(0)).toBe('Free') }) })
External references
- iso-25010:2011 · maintainability.testability — Maintainability — Testability
Taxons
History
- 2026-04-18·v1.0.0·Initial import from code-quality-essentials·automated