FAQ
Mocking Dates and Timers with Vitest
Vue's scheduler depends on the system time. Make sure to mount components after calling vi.setSystemTime, since Vue depends on its side effects. Mounting components before calling vi.setSystemTime may cause breaks in reactivity.
Vue warn: Failed setting prop
[Vue warn]: Failed setting prop "prefix" on <component-stub>: value foo is invalid.
TypeError: Cannot set property prefix of #<Element> which has only a getterThis warning is shown in case you are using shallowMount or stubs with a property name that is shared with Element.
Common property names that are shared with Element:
attributeschildrenprefix
See: https://developer.mozilla.org/en-US/docs/Web/API/Element
Possible solutions
- Use
mountinstead ofshallowMountto render without stubs - Ignore the warning by mocking
console.warn - Rename the prop to not clash with
Elementproperties