diff --git a/packages/testing/src/testing.ts b/packages/testing/src/testing.ts index 0b4db94f57..50b662682e 100644 --- a/packages/testing/src/testing.ts +++ b/packages/testing/src/testing.ts @@ -18,6 +18,7 @@ import { StateTree, _DeepPartial, PiniaPluginContext, + getActivePinia, } from 'pinia' export interface TestingOptions { @@ -106,7 +107,7 @@ export function createTestingPinia({ fakeApp = false, createSpy: _createSpy, }: TestingOptions = {}): TestingPinia { - const pinia = createPinia() + const pinia = getActivePinia() ?? createPinia() // allow adding initial state pinia._p.push(({ store }) => {