Frontend Run Unit Tests (frontend_run_unit_tests)
This skill defines the Level 2 Verification Gate in the Autonomous Frontend Engineering Loop. It validates component logic, state transitions, utility functions, and hooks in an isolated ESM environment using Vitest and happy-dom.
Verification Scope
- Component rendering assertions using React Testing Library or
@testing-library/react. - State reducer and hook behavior.
- Data transformation and utility function invariants.
Execution
Run Unit Tests with JSON Reporter Execute the test runner helper script:
bash .agents/skills/frontend-run-unit-tests/scripts/run_unit_tests.shOr execute directly:
npx vitest run --reporter=json --outputFile=test-results/vitest-results.jsonDiagnose Test Failures
- Review failing test titles, expected vs. received values in assertion diffs.
- Inspect call stack traces to localize whether the failure is in component implementation or test setup.
- Apply single-responsibility corrections directly to the component or mock.
Re-Verification Re-run the runner after adjustments. Ensure all suites pass before proceeding to Level 3 E2E testing.