BetaViberTest is in active development — expect breaking changes.
Overview
#010highCode QualityDisabled by default
Missing Tests
Detects projects with no tests, low coverage, empty tests, or trivial assertions.
Rule ID:
missing-testsExamples#
BadNo tests, empty tests, trivial assertions
// No test files in the entire project!
// Or: empty test
it('should work', () => {
// TODO: write test
});
// Or: trivial assertion
it('test 1', () => {
expect(true).toBe(true);
});
// Or: generic test name
it('works', () => {
const result = add(1, 2);
expect(result).toBe(3);
});GoodDescriptive tests with real assertions
describe('calculateDiscount', () => {
it('should apply percentage discount to subtotal', () => {
const result = calculateDiscount(100, 0.2);
expect(result).toBe(80);
});
it('should return original price when discount is 0', () => {
const result = calculateDiscount(100, 0);
expect(result).toBe(100);
});
it('should throw when discount exceeds 100%', () => {
expect(() => calculateDiscount(100, 1.5))
.toThrow('Discount cannot exceed 100%');
});
});What It Detects#
highZero test files in the project
No test files found in the project
Fix: Set up a testing framework: npm install -D vitest.
highTest ratio below minTestRatio
Low test coverage: {testFiles} test files for {sourceFiles} source files
Fix: Prioritize testing critical business logic and edge cases.
highEmpty test block with no implementation
Empty test: "{testName}" has no implementation
Fix: Add assertions to this test or remove it.
mediumTrivial assertion (expect(true).toBe(true))
Trivial assertion that tests nothing meaningful
Fix: Replace with assertions that test actual behavior.
lowGeneric test name ("it works", "test 1")
Generic test name doesn't describe what's being tested
Fix: Use descriptive names: "should return 404 when user not found".
Configurable Thresholds#
| Option | Default | Description |
|---|---|---|
| minTestRatio | 0.05 | Minimum test-to-source file ratio (0-1) |
Configuration#
This rule is disabled by default. To enable it:
.vibertestrc.jsonjson
{
"rules": {
"missing-tests": {
"enabled": true
}
}
}Learn more: vitest.dev/guide/