vitest-testing
/vitest-testing
Pisze i przegląda testy Vitest z jasnymi asercjami o zachowaniu, odpowiednimi importami, snapshotami plikowymi dla wyjścia terminala i czytelnymi fixture'ami.
- Autor
- ryoppippi ↗
- Repozytorium
- dotfiles ↗
- Licencja
- MIT
- Ostatnia zmiana repozytorium
- 26.10.2026
Ocena i bezpieczeństwo
- Pliki w paczce
- 1
- Skrypty
- 0
- Komentarze HTML
- 0
- Adresy URL w SKILL.md
- 0
Brak sygnałów. Repozytorium zmienione 26.10.2026, bez odwołań do wycofanych modeli i API.
MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.
Co robi i kiedy
Pisze i przegląda testy Vitest z jasnymi asercjami o zachowaniu, odpowiednimi importami, snapshotami plikowymi dla wyjścia terminala i czytelnymi fixture'ami.
Oryginalny opis (EN)
Write or review Vitest tests with clear behaviour-focused assertions, appropriate globals/imports, file snapshots for terminal output, and readable fixture setup. Use when adding tests, fixing Vitest failures, or improving TypeScript test quality.
Jak działa
- Setup
- Readability
- Output Tests
- Examples
Podgląd SKILL.md
---
name: vitest-testing
description: Write or review Vitest tests with clear behaviour-focused assertions, appropriate globals/imports, file snapshots for terminal output, and readable fixture setup. Use when adding tests, fixing Vitest failures, or improving TypeScript test quality.
---
# Vitest Testing
Use the `tdd` skill when the task is a logic change or bug fix that should start with a failing test. This skill covers Vitest-specific test shape and review rules.
## Setup
- Check `vitest.config.*` before assuming globals are enabled.
- If globals are enabled, use `describe`, `it`, `expect`, `vi`, `beforeEach`, and `assert` directly without importing them.
- If globals are not enabled, import only the Vitest APIs used by the file.
- Avoid `await import()` and other dynamic imports in tests unless the behaviour under test is dynamic loading.
- Use `vi.stubEnv()` instead of mutating `process.env` directly.
## Readability
- Test one behaviour per `it`.
- Name tests after observable behaviour, not implementation details.
- Avoid `try`/`catch` for expected failures. Use `expect(...).toThrow()`, `await expect(...).rejects`, or explicit Result failure assertions.
- Avoid `if` branches inside test bodies. Split behaviours into separate tests or use `it.each` for table-driven cases.
- KISS > DRY: do not over-DRY tests. Keep repeated setup inline when it makes the behaviour easier to read.
- Keep assertions in the test unless a helper name is clearer than the assertion it hides.
- Use `assert` to make preconditions explicit and narrow nullable values instead of using non-null assertions.
## Output Tests
- Prefer JSON assertions for structured behaviour.
- Use file snapshots with `toMatchFileSnapshot` for human-readable CLI/table output so layout changes are reviewable.
- For responsive terminal output, capture or set the terminal width used by the command.
## Examples
Expected failure:
```ts
it('rejects invalid config', async () => {
await expect(loadConfig('bad.json')).rejects.toThrow(Error);
});
```
Table-driven case:
```ts
it.each([
['daily', '2026-05-16'],
['monthly', '2026-05'],
])('groups %s rows by period', (reportType, expectedPeriod) => {
const rows = groupUsage(reportType, usage);
expect(rows[0]?.period).toBe(expectedPeriod);
});
```
Narrowing with `assert`:
```ts
it('returns the first row', () => {
const rows = getRows();
const firstRow = rows[0];
assert.isDefined(firstRow, 'expected at least one row');
expect(firstRow.id).toBe('row-1');
});
```
Wersje
| Repozytorium | Wynik | Licencja |
|---|---|---|
| Ta strona · ryoppippi/dotfiles | 100 | MIT |
| laurigates/claude-plugins | 100 | MIT |
| secondsky/claude-skills | 100 | MIT |
| existential-birds/beagle | 100 | Apache-2.0 |
Migawka bazy z 28.10.2026 · wersja paczki 4deb59f6a00c (skrót SHA-256 całej paczki)
Pobrania w ostatnich 30 dniach: 0 · ranking
Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.
Podobne skille
- 100typescript-testing
Pisze testy TypeScript w Jest lub Vitest: testy jednostkowe i integracyjne, mocki oraz pokrycie kodu. - 90vitest-guide
Pomaga pisać testy w Vitest 3 w TypeScript: mocki, asercje HTTP, testy CORS i poprawność typów w testach. - 100vitest-testing-patterns
Pisze testy w Vitest i React Testing Library: testy jednostkowe, komponentów i integracyjne, mockowanie zależności, pokrycie i dobre praktyki. - 100vitest-testing-patterns
Pisze testy w Vitest i React Testing Library: testy jednostkowe, komponentów i integracyjne, mockowanie zależności, pokrycie i dobre praktyki. - 100react-vitest
Dodaje i poprawia testy w projekcie React z Vitest: testy komponentów z Testing Library, mockowanie hooków i konfiguracja pokrycia. - 100testing-react
Pisze testy komponentów, hooków i utilities w React i TypeScript przy użyciu Vitest oraz React Testing Library.