Closed xibman closed 1 month ago
The error you're encountering is likely due to Vue's reactivity system trying to track or modify a property on a reactive object that hasn't been properly initialized. Here's how you can address this issue:
Ensure all reactive properties are initialized: Before modifying or tracking properties on a reactive object, make sure they are initialized. This is important because Vue 3's reactivity system, which relies on JavaScript Proxies, needs to be aware of these properties to track their changes.
Handle dynamic properties correctly: If your component or test dynamically adds new properties to a reactive object, you must ensure these properties are made reactive. This can be achieved by reassigning the reactive object with a new object that includes the new property, using either the spread operator or Object.assign
.
Check your mountSuspended
usage: Make sure that the component and any props passed to it are correctly set up. If your component's setup function or test setup involves dynamically adding properties to objects, these properties should be initialized beforehand.
Debugging: If the problem persists, add debug statements to verify that all expected properties are present and reactive before any operations are performed on them.
Here's an example of how to handle dynamic properties in a reactive object within Vue 3:
// Assuming `reactiveObject` is a reactive object and you need to add a new property
const newProperty = { key: 'value' };
// Reassign the object to include the new property, maintaining reactivity
reactiveObject = reactive({ ...reactiveObject, ...newProperty });
This ensures Vue's reactivity system can track the new property, helping to avoid the error you're facing. For more detailed guidance, consider reviewing the source code of the @nuxt/test-utils
package, especially the implementation of mountSuspended
.
To continue the conversation, mention @dosu.
If the constant is renamed to formError
for example the problem disappear !
Seems like this is the same issue as in https://github.com/nuxt/test-utils/issues/684
@lutejka totally !
Closing in favor of #684
Environment
Build Modules: -
Reproduction
Just create a simple component with :
Simple test
Describe the bug
Additional context
No response
Logs
No response