Vue · Middle · Question 49 of 75
How do you test a component that uses Pinia stores?
- ✓Correct answer: Mount with
createTestingPinia()as a plugin, which stubs actions and lets you set initial state - 2Stores can't be used in tests
- 3Mock
defineStoreglobally
Explanation
Actions become spies (expect(store.addItem).toHaveBeenCalled()), and initialState seeds the store. Store logic itself is tested separately with setActivePinia(createPinia()).