Jest Vue $route reported an error
When you run jest, you will always report errors in the page that uses $route. When you add the following code to jest, you will report other errors
FALSE:
test('Create groupManage data', async (done) => {
wrapper.vm.$nextTick(() => {
})
done()
})
})
Finally, it was found that the correct router
was not added to the jest file:
import VueRouter from 'vue-router'
describe('groupManage', () => {
const wrapper = mount(groupManage, {
global: {
plugins: [ElementPlus, VueRouter, store], // Remember to add VueRouter
mocks: {
$route: {
params: {
image_uuid: '3' // the data you may use in vue page
}
}
}
}
})
})
Another: createlocalvue has been cancelled in the new Vue test utils
Read More:
- [Solved] Vue Route Error: Uncaught TypeError: (0 , vue__WEBPACK_IMPORTED_MODULE_42__.defineComponent) is not a function
- [Solved] Vue route jumps to the same page many times error: Navigationduplicated
- Vue solves the problem of repeated click navigation route error
- How to Solve Vue route jump repeated clicks Error
- Solve the problem of repeatedly clicking the same route console in Vue to report an error
- [Solved] Install The Latest Version of Jest Error: TypeError: Cannot read property ‘instrument‘ of undefined
- [Solved] vue-roter 4 Error: Error: Invalid route component/Uncaught (in promise) Error: Invalid route component
- [Solved] vue3vite Error: Failed to resolve import “@vue/server-renderer from “src\App.vue“. Does the file exist
- [Solved] Vue Error: Uncaught TypeError: Vue.createApp is not a function
- Full screen scrolling by Vue + Vue awesomeswiper
- Vue warn]: vue3 element Component emit Pass Event Error
- Vue installation @ Vue/cli error: npmerr gyp err
- [Solved] Vue3 Error: Unhandled error during execution of scheduler flush. This is likely a Vue internals bug. P
- Vue2.0: How to Use vue3 api to encapsulate Axios
- [Solved] Vue3.0 Error: The component has been registered but not used vue/no-unused-components, Close eslint
- [Solved] VUE D:\project\vueProject\vue-02\src\components\hello.vue 5:5 error Parsing error: x-invalid-end-tag
- VUE Error: Vue Error in nextTick: “RangeError: Maximum call stack size exceeded“
- Vue elementui: solution for error: avoided redundant navigation to current location: “/xxx”
- [Solved] Vue Error: Avoided redundant navigation to current location:/xxxx
- [Solved] Vue console error: navigationduplicated: avoided redundant navigation to current location