왜 Vitest인가
Vitest는 Vite의 트랜스폼 파이프라인을 재사용하여 매우 빠른 테스트 실행을 제공합니다. Jest 호환 API를 지원합니다.
기본 테스트
import { describe, it, expect } from "vitest";
describe("Calculator", () => {
it("should add two numbers", () => {
expect(add(1, 2)).toBe(3);
});
it("should handle async", async () => {
const result = await fetchData();
expect(result).toMatchSnapshot();
});
});인라인 스냅샷
스냅샷을 별도 파일 대신 테스트 코드 안에 인라인으로 저장합니다.
댓글 0