Mocking/Testing with Getters #944
-
I'm curious what the best practice is regarding testing complex getters. Imagine: When testing this getter on top of the component we have to either: A. Know what the internal implementation of the getter is, and feed it exactly what we need in order for the getter to behave as intended. This is trivial with a getter like "validEmail" but can be complex when parsing for example a user object, and trying to determine permissions, etc. B. Mocking the whole module: import { useStore as useUserStore } from '@/stores/user'
useUserStoremockImplementation(
() => defineStore('user', {
state: () => ({
validEmail: false // replacing getter with state to easily modify it
})
})()
) This can be a little cumbersome to do over and over. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Opened #945 |
Beta Was this translation helpful? Give feedback.
Opened #945