mirror of
https://github.com/robonen/tools.git
synced 2026-03-20 02:44:45 +00:00
35 lines
724 B
Markdown
35 lines
724 B
Markdown
# vitest preset
|
|
|
|
## Purpose
|
|
|
|
Правила для тестов (`*.test.*`, `*.spec.*`, `test/**`, `__tests__/**`).
|
|
|
|
## Key Rules
|
|
|
|
- `vitest/no-conditional-tests`.
|
|
- `vitest/no-import-node-test`.
|
|
- `vitest/prefer-to-be-truthy`, `vitest/prefer-to-be-falsy`.
|
|
- `vitest/prefer-to-have-length`.
|
|
- Relaxations: `eslint/no-unused-vars` и `typescript/no-explicit-any` выключены для тестов.
|
|
|
|
## Examples
|
|
|
|
```ts
|
|
// ✅ Good
|
|
import { describe, it, expect } from 'vitest';
|
|
|
|
describe('list', () => {
|
|
it('has items', () => {
|
|
expect([1, 2, 3]).toHaveLength(3);
|
|
expect(true).toBeTruthy();
|
|
});
|
|
});
|
|
|
|
// ❌ Bad
|
|
if (process.env.CI) {
|
|
it('conditionally runs', () => {
|
|
expect(true).toBe(true);
|
|
});
|
|
}
|
|
```
|