const useMyStore = defineStore({
id: 'arrowInit',
state: () => new MyState(),
- });
+ })
useMyStore()
expect('Detected constructor usage').toHaveBeenWarnedTimes(1)
})
it('does not warn when state is created with a plain object', () => {
const useMyStore = defineStore({
id: 'poInit',
- state: () => ({ someValue: undefined })
+ state: () => ({ someValue: undefined }),
})
useMyStore()
expect('Detected constructor usage').toHaveBeenWarnedTimes(0)
!store.$state.constructor.toString().includes('[native code]')
) {
console.warn(
- `[🍍]: The "state" must be a plain object. It cannot be\n\tstate: () => new MyClass()`
+ `[🍍]: The "state" must be a plain object. It cannot be\n\tstate: () => new MyClass()`
)
}