I am writing a test with Vue jest. But when I say run:test "No PrimeVue Confirmation provided!" It shows that this error is caused by useToast() and useConfirm() services.
"transformIgnorePatterns": [
"<rootDir>/node_modules/(?!primevue/.*)"
]
I pasted this where I wrote the jest and the final version was as follows.
"jest": {
"preset": "@vue/cli-plugin-unit-jest",
"transform": {
"^.+\\.vue$": "vue-jest"
},
"transformIgnorePatterns": [
"<rootDir>/node_modules/(?!primevue/.*)"
]
}
It continued to give errors in this state.
I also added PrimeVue globally in the .spec.js file I wrote a test for.
import PrimeVue from "primevue/config";
const wrapper = mount(VehicleInfo, {
global:{
plugins: [PrimeVue]
},
props: { nationCode:1 }
})
error is here:
No PrimeVue Confirmation provided!
66 | })
> 67 | const confirm = useConfirm()
| ^
68 | const toast=useToast()
This worked for me:
import { useConfirm } from 'primevue/useconfirm';
import PrimeVue from 'primevue/config';
import ConfirmationService from 'primevue/confirmationservice';
const wrapper = shallowMount(MyComponent, {
props: { aProp },
global: {
components: { useConfirm },
plugins: [PrimeVue, ConfirmationService],
},
});