Vue injection warning during unit test #2482
-
ReproductionSteps to reproduce the bugWhen using injection in a setup store, executing tests results in a warning: It seems to me that this warning does not occur when using the store in the actual application. It only appears during unit tests. Expected behaviorNo warning on the console Actual behaviorA warning appears on the console: [Vue warn]: inject() can only be used inside setup() or functional components. Additional informationI'm using Vitest. I i understand the docs[1] correctly, the above way should be correct. Extra question: How can I provide a value during unit tests? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
You need to set the active pinia: https://pinia.vuejs.org/cookbook/testing.html#Unit-testing-a-store |
Beta Was this translation helpful? Give feedback.
You need to set the active pinia: https://pinia.vuejs.org/cookbook/testing.html#Unit-testing-a-store