How can I test action in vuex with vue-test-utils and jest when this actions uses a globalProperties? #1831
-
I'm really new at testing with vue-test-utis/jest, but I've stumbled upon an issue that I'm not sure how to test it. Could someone help me? I have an action in my store that uses a globalProperties and when I try to use it in tests it's not working. Basically this is my test:
And this is the action that I'm trying to write a test:
My problem is that the test suit doesn't know what is global.dashboards.$filters.currency, my globalProperties. I get this error:
On my jest.init.js file I have this config, but the action is not aware of that.
How do I fix it? Or ignore that piece of code while testing? Is there a better way to test this action? Thanks in advance. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
You are testing your vuex action without a component. On this case there is no need for |
Beta Was this translation helpful? Give feedback.
You are testing your vuex action without a component. On this case there is no need for
@vue/test-utils
as this is just plain javascript. Where doesglobal.dashboards
coming from outside of your test environment?