Loading...
Loading...
Comprehensive vitest testing patterns covering test structure, AAA pattern, parameterized tests, assertions, mocking, test doubles, error handling, async testing, and performance optimization. Use when writing, reviewing, or refactoring vitest tests, or when user mentions vitest, testing, TDD, test coverage, mocking, assertions, or test files (*.test.ts, *.spec.ts).
npx skill4agent add pageai-pro/ralph-loop vitest-best-practices*.test.ts*.spec.tsvitestdescribeitexpectvibeforeEachafterEachbeforeAllafterAllvi.mock()vi.spyOn()vi.fn()expect(...).toEqual().toBe().toThrow()it.each()toEqualtoStrictEqualtoThrowtest('product test', () => {
const p = new ProductService().add({name: 'Widget'});
expect(p.status).toBe('pendingApproval');
});describe('ProductService', () => {
describe('Add new product', () => {
it('should have status "pending approval" when no price is specified', () => {
// Arrange
const productService = new ProductService();
// Act
const newProduct = productService.add({name: 'Widget'});
// Assert
expect(newProduct.status).toEqual('pendingApproval');
});
});
});toEqualtoBetoStrictEqual