vue-composable-testing
Installation
SKILL.md
Vue Composable Testing Guide
Test composables based on their dependency type: Independent (direct testing) or Dependent (requires component context).
Quick Classification
| Type | Characteristics | Testing Approach |
|---|---|---|
| Independent | Uses only reactivity APIs (ref, computed, watch) | Test directly like functions |
| Dependent | Uses lifecycle hooks (onMounted) or inject | Use withSetup or useInjectedSetup helpers |
Testing Independent Composables
Independent composables use only Vue's reactivity system without lifecycle hooks or dependency injection.
// useSum.ts - Independent composable
import type { ComputedRef, Ref } from 'vue'
import { computed } from 'vue'