Reputation: 4680
I am trying to create everything fresh for each tests, for example creating localVue in each test, however, the location seems to be leaking between unit tests. I am using vue-test-utils and jest with vue-router. The way I work around it is to explicitly navigate to '/' at the beginning of each test. Is it inevitable, or is there a way to isolate the tests from each other?
Upvotes: 0
Views: 182
Reputation: 5238
Yes, because you are running tests in an environment with window
on the global, any changes to window
or its properties affect future tests running in the same scope. The best approach is to reset any properties that you're altering in your source code before each test.
Upvotes: 2