You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Before posting an issue, read the FAQ and search the previous issues.
Description
I'm encountering a "TypeError: Cannot read properties of undefined (reading 'form')" error within the sveltekit-superforms library (superForm.js) during testing with Vitest unit tests. This error prevents form data from being processed successfully within tests.
Steps to Reproduce (in Testing)
Create a SvelteKit form using the superForm and superValidate functions.
Within a test (e.g., using Vitest), submit the form with valid data.
The error occurs within the superForm.js file (approximately line 181), where the code attempts to access the form property of an object named postedForm, which is undefined.
Important Note
This issue does not appear when using the forms in a regular (non-test) environment.
Expected Behavior
Form data should be processed correctly by the superForm function, both during testing and in standard application usage.
Actual Behavior
The TypeError is thrown during testing, interrupting form processing within the test environment. Debugging indicates that the postedForm object is undefined when the problematic line executes.
Environment
Svelte version: 4.2.7
SvelteKit version: 2.0.0
sveltekit-superforms version: 2.10.5
joi validation library version: 17.12.2
Node.js version: 21.7.1
Testing framework: Vitest (I had the same issue with Jest)
Other relevant dependencies and versions (if applicable)
Description
I'm encountering a "TypeError: Cannot read properties of undefined (reading 'form')" error within the sveltekit-superforms library (superForm.js) during testing with Vitest unit tests. This error prevents form data from being processed successfully within tests.
Steps to Reproduce (in Testing)
superForm
andsuperValidate
functions.superForm.js
file (approximately line 181), where the code attempts to access theform
property of an object namedpostedForm
, which is undefined.Important Note
This issue does not appear when using the forms in a regular (non-test) environment.
Expected Behavior
Form data should be processed correctly by the superForm function, both during testing and in standard application usage.
Actual Behavior
The TypeError is thrown during testing, interrupting form processing within the test environment. Debugging indicates that the postedForm object is undefined when the problematic line executes.
Environment
Svelte version: 4.2.7
SvelteKit version: 2.0.0
sveltekit-superforms version: 2.10.5
joi validation library version: 17.12.2
Node.js version: 21.7.1
Testing framework: Vitest (I had the same issue with Jest)
Other relevant dependencies and versions (if applicable)
Error
Test File
Component being tested
The text was updated successfully, but these errors were encountered: