I’m trying to set up vitest for a Vue application that was recently converted from Vue 2 to Vue 3. I’m getting the following error, and have been unsuccessful in determining what the problem is. Here is the error I’m getting:
<code>FAIL tests/unit/components/MyComponent.spec.js [ tests/unit/components/MyComponent.spec.js ]
ReferenceError: location is not defined
Module.createWebHashHistory node_modules/vue-router/dist/vue-router.mjs:850:5
src/router/index.js:42:12
40|
41| const router = createRouter({
42| history: createWebHashHistory(),
| ^
43| routes,
44| scrollBehavior(to, from, savedPosition) {
src/components/MyComponent.vue:1:1
</code>
<code>FAIL tests/unit/components/MyComponent.spec.js [ tests/unit/components/MyComponent.spec.js ]
ReferenceError: location is not defined
Module.createWebHashHistory node_modules/vue-router/dist/vue-router.mjs:850:5
src/router/index.js:42:12
40|
41| const router = createRouter({
42| history: createWebHashHistory(),
| ^
43| routes,
44| scrollBehavior(to, from, savedPosition) {
src/components/MyComponent.vue:1:1
</code>
FAIL tests/unit/components/MyComponent.spec.js [ tests/unit/components/MyComponent.spec.js ]
ReferenceError: location is not defined
Module.createWebHashHistory node_modules/vue-router/dist/vue-router.mjs:850:5
src/router/index.js:42:12
40|
41| const router = createRouter({
42| history: createWebHashHistory(),
| ^
43| routes,
44| scrollBehavior(to, from, savedPosition) {
src/components/MyComponent.vue:1:1
Apparently, createWebHashHistory()
references something called location
, but I can’t tell where I should be definining it.
I realize this isn’t much to go on, but at this point I’m just looking for pointers on how to debug this, or things to check. Any help would be appreciated.
Thanks!