Unable to import VueX store into router and router into store in Mocha tests Unable to import VueX store into router and router into store in Mocha tests vue.js vue.js

Unable to import VueX store into router and router into store in Mocha tests


I had the same problem, where the store remained undefined when imported into router.

Eventually I opted for using the router instance itself to access the store:

router.beforeEach((to, from, next) => {  console.log('authenticated?', router.app.$store.getters['auth/isAuthenticated'])// ...

})

Notice that I'm using Namespaced stores, so that might be the issue. Regardless, I quite like this solution.