-
-
Notifications
You must be signed in to change notification settings - Fork 15
Add tests via Vitest to React framework package #54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds comprehensive test infrastructure and test suites to the React framework package using Vitest and React Testing Library.
Changes:
- Adds Vitest configuration with jsdom environment and coverage settings
- Creates test setup file with Testing Library cleanup configuration
- Implements test utility helpers (objectPath, arrayPath, validationIssue, schemaIssue) mirroring the core package
- Adds comprehensive runtime and type tests for all hooks (useForm, useField, useFieldArray, useSignals)
- Adds comprehensive tests for all components (Form, Field, FieldArray)
- Updates unit test documentation guide to reflect renamed helper function from
issuetovalidationIssue - Adds test-related dependencies (@testing-library/react, @testing-library/jest-dom, vitest, jsdom, @vitest/coverage-v8)
Reviewed changes
Copilot reviewed 16 out of 17 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| frameworks/react/vitest.config.ts | Configures Vitest with jsdom environment and coverage exclusions |
| frameworks/react/src/vitest/setup.ts | Sets up Testing Library cleanup after each test |
| frameworks/react/src/vitest/utils.ts | Provides test helper utilities for creating validation issues and path items |
| frameworks/react/src/vitest/index.ts | Exports test utilities |
| frameworks/react/src/hooks/useSignals/useSignals.test.tsx | Tests useSignals hook reactivity and cleanup |
| frameworks/react/src/hooks/useForm/useForm.test.tsx | Tests useForm hook initialization, validation, and store stability |
| frameworks/react/src/hooks/useForm/useForm.test-d.ts | Type tests for useForm hook return types and configuration |
| frameworks/react/src/hooks/useFieldArray/useFieldArray.test.tsx | Tests useFieldArray hook state, operations, and reactivity |
| frameworks/react/src/hooks/useFieldArray/useFieldArray.test-d.ts | Type tests for useFieldArray (contains type assertion issues) |
| frameworks/react/src/hooks/useField/useField.test.tsx | Tests useField hook state, props, and event handlers |
| frameworks/react/src/hooks/useField/useField.test-d.ts | Type tests for useField hook types and props |
| frameworks/react/src/components/Form/Form.test.tsx | Tests Form component rendering, submission, and validation |
| frameworks/react/src/components/FieldArray/FieldArray.test.tsx | Tests FieldArray component rendering and array operations |
| frameworks/react/src/components/Field/Field.test.tsx | Tests Field component rendering, state, and event handling |
| frameworks/react/package.json | Adds test script and testing-related dev dependencies |
| prompts/write-unit-tests.md | Updates helper function names to match current implementation |
| pnpm-lock.yaml | Updates lock file with new dependencies |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
| const form = useForm({ schema }); | ||
| const fieldArray = useFieldArray(form, { path: ['items'] }); | ||
|
|
||
| expectTypeOf(fieldArray.items).toEqualTypeOf<readonly string[]>(); |
Copilot
AI
Jan 17, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Type assertion mismatch: The test expects items to be readonly string[] (an immutable array), but the FieldArrayStore type definition (line 94 in src/types/field.ts) specifies readonly items: string[] (a mutable array). The test should match the actual type definition and use string[] instead of readonly string[].
| const form = useForm({ schema }); | ||
| const fieldArray = useFieldArray(form, { path: ['users'] }); | ||
|
|
||
| expectTypeOf(fieldArray.items).toEqualTypeOf<readonly string[]>(); |
Copilot
AI
Jan 17, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Type assertion mismatch: The test expects items to be readonly string[] (an immutable array), but the FieldArrayStore type definition (line 94 in src/types/field.ts) specifies readonly items: string[] (a mutable array). The test should match the actual type definition and use string[] instead of readonly string[]. Note that items always contains string IDs regardless of whether the array contains objects or primitives.
No description provided.