[Vuejs]-Vue, pinia plugin testing with vitest store.$subscribe not working as expected

0๐Ÿ‘

โœ…

Iโ€™ve finally found the solution:

I had to add the extra option flush: 'sync' to store.$subscribe.

The flush option does not affect calls to store.$patch() and this fixed my problem.

store.$subscribe(
   (mutation, state) => {
        ...
   },
   { flush: 'sync' } <<< ----------- HERE
); 

Leave a comment