---
title: "Testing Pinia stores · vuejs.school"
description: "Test a store with a fresh Pinia in every test, and test the components that use it with createTestingPinia(), where actions are spies and state starts where you need it."
canonical_url: "https://vuejs.school/learn/testing/testing-pinia-stores"
meta:
  "og:description": "Test a store with a fresh Pinia in every test, and test the components that use it with createTestingPinia(), where actions are spies and state starts where you need it."
  "og:image": "https://vuejs.school/_og/d/a_~VGVzdGluZyBQaW5pYSBzdG9yZXMgwrcgdnVlanMuc2Nob29s%2Cc_OgCard.takumi%2Ctitle_Testing%2BPinia%2Bstores%2Cdescription_~VGVzdCBhIHN0b3JlIHdpdGggYSBmcmVzaCBQaW5pYSBpbiBldmVyeSB0ZXN0LCBhbmQgdGVzdCB0aGUgY29tcG9uZW50cyB0aGF0IHVzZSBpdCB3aXRoIGNyZWF0ZVRlc3RpbmdQaW5pYSgpLCB3aGVyZSBhY3Rpb25zIGFyZSBzcGllcyBhbmQgc3RhdGUgc3RhcnRzIHdoZXJlIHlvdSBuZWVkIGl0Lg%2Ceyebrow_~VGVzdGluZyDCtyBMZXNzb24gNCBvZiA3%2Ctint_mint%2Cp_Ii9sZWFybi90ZXN0aW5nL3Rlc3RpbmctcGluaWEtc3RvcmVzIg%2Cs_YXht7T_hOLqTB8-3.png"
  "og:image:alt": "Testing Pinia stores · vuejs.school"
  "og:image:height": "600"
  "og:image:type": image/png
  "og:image:width": "1200"
  "og:title": "Testing Pinia stores · vuejs.school"
  "twitter:image": "https://vuejs.school/_og/d/a_~VGVzdGluZyBQaW5pYSBzdG9yZXMgwrcgdnVlanMuc2Nob29s%2Cc_OgCard.takumi%2Ctitle_Testing%2BPinia%2Bstores%2Cdescription_~VGVzdCBhIHN0b3JlIHdpdGggYSBmcmVzaCBQaW5pYSBpbiBldmVyeSB0ZXN0LCBhbmQgdGVzdCB0aGUgY29tcG9uZW50cyB0aGF0IHVzZSBpdCB3aXRoIGNyZWF0ZVRlc3RpbmdQaW5pYSgpLCB3aGVyZSBhY3Rpb25zIGFyZSBzcGllcyBhbmQgc3RhdGUgc3RhcnRzIHdoZXJlIHlvdSBuZWVkIGl0Lg%2Ceyebrow_~VGVzdGluZyDCtyBMZXNzb24gNCBvZiA3%2Ctint_mint%2Cp_Ii9sZWFybi90ZXN0aW5nL3Rlc3RpbmctcGluaWEtc3RvcmVzIg%2Cs_YXht7T_hOLqTB8-3.png"
  "twitter:image:alt": "Testing Pinia stores · vuejs.school"
---

> Index of every page on this site: [llms.txt](https://vuejs.school/llms.txt)

# **Testing Pinia stores**

Test a store with a fresh Pinia in every test, and test the components that use it with createTestingPinia(), where actions are spies and state starts where you need it.

```json
{"@context":"https://schema.org","@graph":[{"@id":"https://vuejs.school/#website","@type":"WebSite","description":"A free AI-instructed school for Vue.js. Short tutorials, runnable code and quizzes that adapt to you.","name":"vuejs.school","url":"https://vuejs.school/","publisher":{"@id":"https://vuejs.school/#identity"}},{"@id":"https://vuejs.school/learn/testing/testing-pinia-stores#webpage","@type":"WebPage","description":"Test a store with a fresh Pinia in every test, and test the components that use it with createTestingPinia(), where actions are spies and state starts where you need it.","name":"Testing Pinia stores","url":"https://vuejs.school/learn/testing/testing-pinia-stores","breadcrumb":{"@id":"https://vuejs.school/learn/testing/testing-pinia-stores#breadcrumb"},"isPartOf":{"@id":"https://vuejs.school/#website"},"potentialAction":[{"@type":"ReadAction","target":["https://vuejs.school/learn/testing/testing-pinia-stores"]}],"primaryImageOfPage":{"@id":"https://vuejs.school/#logo"}},{"@id":"https://vuejs.school/#identity","@type":"Organization","description":"A free AI-instructed school for Vue.js. Short tutorials, runnable code and quizzes that adapt to you.","name":"vuejs.school","url":"https://vuejs.school","logo":{"@id":"https://vuejs.school/#logo"}},{"@id":"https://vuejs.school/learn/testing/testing-pinia-stores#article","description":"Test a store with a fresh Pinia in every test, and test the components that use it with createTestingPinia(), where actions are spies and state starts where you need it.","headline":"Testing Pinia stores","inLanguage":"en","isAccessibleForFree":true,"thumbnailUrl":"https://vuejs.school/_og/d/a_~VGVzdGluZyBQaW5pYSBzdG9yZXMgwrcgdnVlanMuc2Nob29s%2Cc_OgCard.takumi%2Ctitle_Testing%2BPinia%2Bstores%2Cdescription_~VGVzdCBhIHN0b3JlIHdpdGggYSBmcmVzaCBQaW5pYSBpbiBldmVyeSB0ZXN0LCBhbmQgdGVzdCB0aGUgY29tcG9uZW50cyB0aGF0IHVzZSBpdCB3aXRoIGNyZWF0ZVRlc3RpbmdQaW5pYSgpLCB3aGVyZSBhY3Rpb25zIGFyZSBzcGllcyBhbmQgc3RhdGUgc3RhcnRzIHdoZXJlIHlvdSBuZWVkIGl0Lg%2Ceyebrow_~VGVzdGluZyDCtyBMZXNzb24gNCBvZiA3%2Ctint_mint%2Cp_Ii9sZWFybi90ZXN0aW5nL3Rlc3RpbmctcGluaWEtc3RvcmVzIg%2Cs_YXht7T_hOLqTB8-3.png","@type":["Article","TechArticle"],"articleSection":["Testing"],"author":{"@id":"https://vuejs.school/#identity"},"image":{"@id":"https://vuejs.school/#/schema/image/1"},"isPartOf":{"@id":"https://vuejs.school/learn/testing/testing-pinia-stores#webpage"},"keywords":["setActivePinia()","createTestingPinia()","stubActions","initialState","vi.mocked()"],"mainEntityOfPage":{"@id":"https://vuejs.school/learn/testing/testing-pinia-stores#webpage"},"publisher":{"@id":"https://vuejs.school/#identity"}},{"@id":"https://vuejs.school/learn/testing/testing-pinia-stores#breadcrumb","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","name":"Skill tree","item":"https://vuejs.school/track","position":1},{"@type":"ListItem","name":"Testing","item":"https://vuejs.school/track/testing","position":2},{"@type":"ListItem","name":"Testing Pinia stores","position":3}]},{"@id":"https://vuejs.school/#logo","@type":"ImageObject","caption":"vuejs.school","contentUrl":"https://vuejs.school/apple-touch-icon.png","inLanguage":"en","url":"https://vuejs.school/apple-touch-icon.png"},{"@id":"https://vuejs.school/#/schema/image/1","@type":"ImageObject","contentUrl":"https://vuejs.school/_og/d/a_~VGVzdGluZyBQaW5pYSBzdG9yZXMgwrcgdnVlanMuc2Nob29s%2Cc_OgCard.takumi%2Ctitle_Testing%2BPinia%2Bstores%2Cdescription_~VGVzdCBhIHN0b3JlIHdpdGggYSBmcmVzaCBQaW5pYSBpbiBldmVyeSB0ZXN0LCBhbmQgdGVzdCB0aGUgY29tcG9uZW50cyB0aGF0IHVzZSBpdCB3aXRoIGNyZWF0ZVRlc3RpbmdQaW5pYSgpLCB3aGVyZSBhY3Rpb25zIGFyZSBzcGllcyBhbmQgc3RhdGUgc3RhcnRzIHdoZXJlIHlvdSBuZWVkIGl0Lg%2Ceyebrow_~VGVzdGluZyDCtyBMZXNzb24gNCBvZiA3%2Ctint_mint%2Cp_Ii9sZWFybi90ZXN0aW5nL3Rlc3RpbmctcGluaWEtc3RvcmVzIg%2Cs_YXht7T_hOLqTB8-3.png","inLanguage":"en","url":"https://vuejs.school/_og/d/a_~VGVzdGluZyBQaW5pYSBzdG9yZXMgwrcgdnVlanMuc2Nob29s%2Cc_OgCard.takumi%2Ctitle_Testing%2BPinia%2Bstores%2Cdescription_~VGVzdCBhIHN0b3JlIHdpdGggYSBmcmVzaCBQaW5pYSBpbiBldmVyeSB0ZXN0LCBhbmQgdGVzdCB0aGUgY29tcG9uZW50cyB0aGF0IHVzZSBpdCB3aXRoIGNyZWF0ZVRlc3RpbmdQaW5pYSgpLCB3aGVyZSBhY3Rpb25zIGFyZSBzcGllcyBhbmQgc3RhdGUgc3RhcnRzIHdoZXJlIHlvdSBuZWVkIGl0Lg%2Ceyebrow_~VGVzdGluZyDCtyBMZXNzb24gNCBvZiA3%2Ctint_mint%2Cp_Ii9sZWFybi90ZXN0aW5nL3Rlc3RpbmctcGluaWEtc3RvcmVzIg%2Cs_YXht7T_hOLqTB8-3.png"}]}
```