When working on a Vue jest test, I encountered an error message "No PrimeVue Confirmation provided!" which seemed to be related to the useToast() and useConfirm() services.
"transformIgnorePatterns": [
"<rootDir>/node_modules/(?!primevue/.*)"
]
I added this code snippet while configuring jest and the final version looked like this:
"jest": {
"preset": "@vue/cli-plugin-unit-jest",
"transform": {
"^.+\\.vue$": "vue-jest"
},
"transformIgnorePatterns": [
"<rootDir>/node_modules/(?!primevue/.*)"
]
}
However, the errors persisted even after making these changes.
To address the issue, I globally imported PrimeVue in the .spec.js file where my test was located.
import PrimeVue from "primevue/config";
const wrapper = mount(VehicleInfo, {
global:{
plugins: [PrimeVue]
},
props: { nationCode:1 }
})
The specific error occurred at this part of the code:
No PrimeVue Confirmation provided!
66 | })
> 67 | const confirm = useConfirm()
| ^
68 | const toast=useToast()