Need help to test pinia store using router #2239
-
|
I am using pinia with vite-ssg. I can use this.router.push function in my store and all works perfectly. Unfortunately i get an error running test "Cannot read properties of undefined (reading 'push')" from this.router.push function. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
|
Hi, I just had the exact same problem. What solved it for me was to add a fake app (as is actually described in the Pinia documentation in the Testing section), like so: Because according to the documentation without an app, plugins (in this case the router) will not actually be added to pinia. |
Beta Was this translation helpful? Give feedback.
-
|
I've encountered the same problem. For some reason creating fake app doesn't seem to work |
Beta Was this translation helpful? Give feedback.
Hi,
I just had the exact same problem. What solved it for me was to add a fake app (as is actually described in the Pinia documentation in the Testing section), like so:
Because according to the documentation without an app, plugins (in this case the router) will not actually be added to pinia.