Add Vitest testing framework with comprehensive demo tests #21
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This PR adds Vitest as the testing framework for the React Performance Examples app and implements comprehensive tests for all four demo implementations, focusing on click interactions and render token behavior.
Problem
The repository had no automated testing to verify that the performance demos work correctly and exhibit the expected render behavior. Without tests, it was difficult to:
Solution
Added Vitest with 18 tests across all four demos that validate:
Render Token Behavior
Tests verify the render token system works correctly, showing
«001
on initial render and incrementing appropriately on interactions:Performance Characteristics
User Interactions
All click interactions tested:
Changes
Testing Infrastructure
vite.config.ts
src/test/setup.ts
) with:scrollIntoView
mock for jsdom compatibilitynpm test
,npm run test:ui
,npm run test:run
Test Files (18 tests)
src/examples/zustand/ZustandRenderDemo.test.tsx
(4 tests)src/examples/zustand-query/ZustandQuery.test.tsx
(5 tests)src/examples/propDrilling/PropDrillingRenderDemo.test.tsx
(4 tests)src/examples/propDrillingNaive/PropDrillingNaiveRenderDemo.test.tsx
(5 tests)Documentation
TESTING.md
with usage guide and testing patternsDependencies Added
vitest
- Fast test runner built on Vite@testing-library/react
- React component testing utilities@testing-library/jest-dom
- Custom DOM matchers@testing-library/user-event
- Realistic user interaction simulationjsdom
- DOM implementation for Node.jsVerification
✅ All 18 tests pass consistently
✅ ESLint passes with no errors
✅ TypeScript compilation succeeds
✅ Production build completes successfully
Example Usage
The tests ensure the educational value of the repository is maintained by making performance characteristics observable and testable through the render token system.
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.