Testing component methods
In the previous version of Vue, the recommendation would have been to do testing on filters and mixins, but typically avoid writing tests for methods as they aren’t directly called by users.
In Vue 3, both filters and mixins are deprecated and replaced with regular methods and computed properties. That being said, finding the methods appropriate for tests may require some thought.
Consider a computed
property that truncates its input to eight characters:
// rest of file… import { computed } from 'vue'; const props = defineProps({ title: { type: String }, description: { type: String }, tags: { type: Array, default: () => [] } }) const truncated = computed(() => { return props.description && props.description.slice(0,8) }) defineExpose...