testing
pytest, Vitest, Playwright testing patterns for Pulse Radar.
When & Why to Use This Skill
This Claude skill provides a comprehensive framework for full-stack automated testing, specifically optimized for the Pulse Radar ecosystem. It integrates industry-standard tools like pytest for backend services, Vitest for frontend components, and Playwright for end-to-end browser automation. By enforcing strict testing patterns and critical quality rules—such as mandatory assertion messages and a 'no-skip' policy—it ensures robust code reliability and prevents regressions across the entire development lifecycle.
Use Cases
- Backend API Validation: Writing asynchronous test cases for database services and CRUD operations using pytest and pytest-asyncio to ensure data integrity.
- Frontend Component Testing: Developing unit tests for React/TypeScript components with Vitest and Testing Library to verify user interactions and UI logic.
- End-to-End (E2E) User Flows: Automating complex browser scenarios with Playwright to validate critical paths like dashboard loading and network-idle states.
- Automated Quality Enforcement: Applying standardized testing rules to ensure that tests are never bypassed and that every failure provides descriptive, actionable debug messages.
| name | testing |
|---|---|
| description | pytest, Vitest, Playwright testing patterns for Pulse Radar. |
Testing Skill
Test Coverage
| Layer | Count | Tools |
|---|---|---|
| Backend | 521 tests | pytest, pytest-asyncio |
| Frontend | 51 tests | Vitest, Testing Library |
| E2E | 13 specs | Playwright |
| Visual | 65 stories | Storybook |
Backend Test Pattern
@pytest.mark.asyncio
async def test_atom_service_create(db_session: AsyncSession):
service = AtomService(AtomCRUD(db_session))
atom = await service.create(AtomCreate(content="test", atom_type=AtomType.INSIGHT))
assert atom.id is not None, f"Atom ID missing"
assert atom.status == AtomStatus.DRAFT, f"Expected DRAFT, got {atom.status}"
Frontend Test Pattern
describe('BulkActionsToolbar', () => {
it('should call onSelectAll when clicked', () => {
const onSelectAll = vi.fn();
render(<BulkActionsToolbar onSelectAll={onSelectAll} />);
fireEvent.click(screen.getByRole('checkbox'));
expect(onSelectAll).toHaveBeenCalledTimes(1);
});
});
E2E Test Pattern
test.describe('Dashboard', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/dashboard');
await page.waitForLoadState('networkidle');
});
test('loads successfully', async ({ page }) => {
await expect(page.locator('h1:has-text("Dashboard")')).toBeVisible();
});
});
Critical Rules
Assertion messages required
assert x == y, f"Expected {y}, got {x}: {context}"Never sabotage tests — no skip, no comment out, no always-green
Test must fail on breakage — if UI breaks and test passes, test is bad
References
- @references/pytest.md — Fixtures, factories, async patterns
- @references/vitest.md — Component testing, hook testing
- @references/playwright.md — E2E flows, accessibility testing