File tree Expand file tree Collapse file tree 2 files changed +14
-10
lines changed Expand file tree Collapse file tree 2 files changed +14
-10
lines changed Original file line number Diff line number Diff line change @@ -176,8 +176,8 @@ const wrapper = mount(Counter, {
176176 global: {
177177 plugins: [
178178 createTestingPinia ({
179- stubActions: [' increment' , ' reset' ]
180- })
179+ stubActions: [' increment' , ' reset' ],
180+ }),
181181 ],
182182 },
183183})
@@ -209,8 +209,8 @@ const wrapper = mount(Counter, {
209209 if (store .isPremium ) return false
210210
211211 return true
212- }
213- })
212+ },
213+ }),
214214 ],
215215 },
216216})
@@ -225,8 +225,10 @@ store.fetchData() // executed or stubbed based on initial store.isPremium
225225```
226226
227227::: tip
228- - An empty array ` [] ` means no actions will be stubbed (all actions execute normally)
228+
229+ - An empty array ` [] ` means no actions will be stubbed (same as ` false ` )
229230- The function is evaluated once at store setup time, receiving the store instance in its initial state
231+
230232:::
231233
232234You can also manually mock specific actions after creating the store:
Original file line number Diff line number Diff line change @@ -183,8 +183,8 @@ const wrapper = mount(Counter, {
183183 global: {
184184 plugins: [
185185 createTestingPinia ({
186- stubActions: [' increment' , ' reset' ]
187- })
186+ stubActions: [' increment' , ' reset' ],
187+ }),
188188 ],
189189 },
190190})
@@ -216,8 +216,8 @@ const wrapper = mount(Counter, {
216216 if (store .isPremium ) return false
217217
218218 return true
219- }
220- })
219+ },
220+ }),
221221 ],
222222 },
223223})
@@ -232,8 +232,10 @@ store.fetchData() // 根据初始 store.isPremium 执行或存根
232232```
233233
234234::: tip
235- - 空数组 ` [] ` 表示不存根任何 action(所有 action 正常执行)
235+
236+ - 空数组 ` [] ` 表示不存根任何 action(与 ` false ` 相同)
236237- 函数在 store 设置时被评估一次,接收处于初始状态的 store 实例
238+
237239:::
238240
239241你也可以在创建 store 后手动模拟特定的 action:
You can’t perform that action at this time.
0 commit comments