In a .vue file with Composition API (and Vue 3), set up the router:
const router = useRouter()
Mount the .vue file in a jest test:
const wrapper = mount(Lookup)
On execution, produces:
console.warn
[Vue warn]: injection "Symbol([vue-router]: router)" not found.
at <Anonymous ref="VTU_COMPONENT" >
at <VTUROOT>
Mocking it results in the same output:
useRouter().push = jest.fn()
Setting provide results in same output:
import { useRouter } from 'vue-router'
...
const wrapper = mount(Lookup, {
global: {
plugins: [useRouter],
provide: {
router: {},
},
},
})