Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Unit tests do not run when importing router into store and store into router #1509
Steps to reproduce
What is expected?
The tests should run fine and circular imports should work. They DO work in the browser just not in Mocha testing environment.
What is actually happening?
Error as follows:
My VueX store needs to be able to import the router so it can do routing things like navigate to another page.
I have asked for help on Stack Overflow:
You created a circular dependency, which will always break like this. It has nothing to do with the tings you import/export (store/router).
You can prevent this by importing one of the two dependencies qith
Professional opinion: This is definitely not the job of the store. The store actions etc should be oblivious to the routing system.
Depending on the exact use case you might consider implementing these side effects as a store plugin:
If you need help with that, visit our forum or chat.