## Option Stores
+<MasteringPiniaLink
+ href="https://masteringpinia.com/lessons/using-composables-in-option-stores"
+ title="Using Composables in Option Stores"
+/>
+
When defining an option store, you can call a composable inside of the `state` property:
```ts
## Setup Stores
+<MasteringPiniaLink
+ href="https://masteringpinia.com/lessons/using-composables-in-setup-stores"
+ title="Using Composables in Setup Stores"
+/>
+
On the other hand, when defining a setup store, you can use almost any composable since every property gets discerned into state, action, or getter:
```ts
# Testing stores
+<MasteringPiniaLink
+ href="https://masteringpinia.com/lessons/introduction-to-testing-stores"
+ title="Learn how to test stores"
+/>
+
Stores will, by design, be used at many places and can make testing much harder than it should be. Fortunately, this doesn't have to be the case. We need to take care of three things when testing stores:
- The `pinia` instance: Stores cannot work without it
## Option Stores %{#option-stores}%
+<MasteringPiniaLink
+ href="https://masteringpinia.com/lessons/using-composables-in-option-stores"
+ title="Using Composables in Option Stores"
+/>
+
当定义一个 option store 时,你可以在 `state` 属性中调用组合式函数:
```ts
## Setup Stores %{#setup-stores}%
+<MasteringPiniaLink
+ href="https://masteringpinia.com/lessons/using-composables-in-setup-stores"
+ title="Using Composables in Setup Stores"
+/>
+
另外,当定义一个 setup store 时,你几乎可以使用任何组合式函数,因为每一个属性都会被辨别为 state 、action 或者 getter:
```ts
# store 测试 %{#testing-stores}%
+<MasteringPiniaLink
+ href="https://masteringpinia.com/lessons/introduction-to-testing-stores"
+ title="Learn how to test stores"
+/>
+
从设计上来说,许多地方都会使用 store,所以可能比正常情况更难测试。但幸运的是,这不一定是真的。在测试 store 时,我们需要注意三件事:
- `pinia` 实例:没有它,store 不能正常工作