Skip to content

Conversation

@BrendanC23
Copy link

@BrendanC23 BrendanC23 commented Jan 28, 2026

  1. Remove /\\. from vitest.config.ts. This was necessary to fix the error No test files found. This can also be fixed by updating Vitest to version 4, but this has a change to how snapshots are stored. See the migration guide. All of the tests are found by removing /\\., so the Vitest upgrade is better in a later PR.
  2. Inlined z in vitest.config.ts to spy on parse() from zod/v4/core. Without this, a TypeError: Cannot redefine property: parse error occurs.
  3. Change bun test to bun run test in CONTRIBUTING.md. bun test runs Bun's native test runner, not the test script.
  4. Add Test stage to .github/workflows/main.yml. It was removed in this PR and the tests haven't been running in CI.
  5. Fix failing tests

Notes:

  1. All
    • Fixed tests that called useForm outside of a component. This fixed the errors Error: Invalid hook call. Hooks can only be called inside of the body of a function component. and TypeError: Cannot read properties of null (reading 'useRef').
  2. Arktype
    • This PR changed from directly calling Arktype to using standard schema. Part of this transition was changing type: error.code to type: '' (because error.code is not part of the standard schema). This required an update to the snapshot.
  3. Superstruct
    • Fix validation of schemas that perform coercion ({ coerce: true } must be passed in)
    • Added additional overload for type definition superstructResolver that improves handling of coerced schemas (This fixes a type error with the form values).
    • Fix definition of coercion schema so that it correctly converts from number to string
    • As mentioned in this issue, there is no way to infer the input type of a coerced schema. A separate PR would be necessary. Some of the type inference tests have been changed to manually provide the input type (this enables watch to return the correct value for a coerced schema).
  4. Typeschema
    • The for loop was looping through the schemaErrors variable, but the current error was based on the typeschemaErrors[0] variable. This caused only the first error to be returned.
    • Change from spying on typeschema.validate to watching schema["~standard"]
  5. Zod
    • Fixed Zod tests that spied on schema.parse() instead of z4.parse()
    • Added missing snapshots

Fixes #832

1. Remove `/\\.` from `vitest.config.ts`. This was necessary to fix the error `No test files found`. This can also be fixed by updating Vitest to version 4, but this has a change to how snapshots are stored. See [the migration guide](https://vitest.dev/guide/migration.html#changes-to-mocking). All of the tests are found by removing `/\\.`, so the Vitest upgrade is better in a later PR.
1. Inlined `z` in `vitest.config.ts` to spy on `parse()` from `zod/v4/core`. Without this, a `TypeError: Cannot redefine property: parse` error occurs.
1. Change `bun test` to `bun run test` in CONTRIBUTING.md. `bun test` runs Bun's native test runner, not the `test` script.
1. Add `Test` stage to `.github/workflows/main.yml`. It was removed in [this PR](react-hook-form#699) and the tests haven't been running in CI.
1. Fix failing tests

Notes:

1. All
    * Fixed tests that called `useForm` outside of a component. This fixed the errors `Error: Invalid hook call. Hooks can only be called inside of the body of a function component.` and `TypeError: Cannot read properties of null (reading 'useRef')`.
1. Arktype
    * [This PR](react-hook-form#753) changed from directly calling Arktype to using standard schema. Part of this transition was changing `type: error.code` to `type: ''` (because `error.code` is not part of the standard schema). This required an update to the snapshot.
1. Superstruct
    * Fix validation of schemas that perform coercion (`{ coerce: true }` must be passed in)
    * Added additional overload for type definition `superstructResolver` that improves handling of coerced schemas (This fixes a type error with the form values).
    * Fix definition of coercion schema so that it correctly converts from number to string
    * As mentioned in [this issue](ianstormtaylor/superstruct#1159), there is no way to infer the input type of a coerced schema. A [separate PR](ianstormtaylor/superstruct#1181) would be necessary. Some of the type inference tests have been changed to manually provide the input type (this enables `watch` to return the correct value for a coerced schema).
1. Typeschema
    * The `for` loop was looping through the `schemaErrors` variable, but the current error was based on the `typeschemaErrors[0]` variable. This caused only the first error to be returned.
    * Change from spying on `typeschema.validate` to watching `schema["~standard"]`
1. Zod
    * Fixed Zod tests that spied on `schema.parse()` instead of `z4.parse()`
    * Added missing snapshots
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Many tests failing

1 participant