2

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()

1 Answer 1

3

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],
  },
});
Sign up to request clarification or add additional context in comments.

1 Comment

Also, I think the problem with file formats that required you to add transformIgnorePatterns for primevue files has gone away, so you should not need that anymore.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.