testing-typescript
TypeScript testing with Vitest/Jest: file structure, mocking strategy, async patterns, and coverage targets
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
TypeScript testing with Vitest/Jest: file structure, mocking strategy, async patterns, and coverage targets
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Architecture decisions: layering, design patterns, microservices trade-offs, and domain-driven design
Python architecture: PEP-8, type hints, clean layering, dependency injection, and testing strategy
General code review process: priority ordering, what to block on, how to give actionable feedback
Python data science: notebook structure, data validation, reproducibility, and model documentation
Git workflow: branch naming, conventional commits, PR conventions, and merge strategies
TypeScript refactoring: SOLID principles, DRY, type safety improvements, and eliminating code smells
| name | testing-typescript |
| description | TypeScript testing with Vitest/Jest: file structure, mocking strategy, async patterns, and coverage targets |
vitest run / vitest run --coveragesrc/utils/format.ts → src/utils/format.test.tstests/fixtures/ or src/__tests__/helpers/describe('formatDate', () => {
it('should return ISO date string when given a valid Date', () => {
// Arrange
const date = new Date('2026-01-15');
// Act
const result = formatDate(date);
// Assert
expect(result).toBe('2026-01-15');
});
});
// Module mock — top of file
vi.mock('../services/emailService');
// Spy without full mock
const spy = vi.spyOn(mailer, 'send').mockResolvedValue(undefined);
// Restore after each test
afterEach(() => vi.restoreAllMocks());
// Time control
beforeEach(() => vi.useFakeTimers());
afterEach(() => vi.useRealTimers());
// Always await; use assertions count for safety
it('should reject with AuthError when token is expired', async () => {
expect.assertions(1);
await expect(verifyToken('expired')).rejects.toThrow('Token expired');
});