diff --git a/packages/framework/esm-framework/mock.tsx b/packages/framework/esm-framework/mock.tsx index 6cc38ef76..1b422e067 100644 --- a/packages/framework/esm-framework/mock.tsx +++ b/packages/framework/esm-framework/mock.tsx @@ -88,30 +88,17 @@ export function createGlobalStore( name: string, initialState: T ): StoreApi { - const available = availableStores[name]; - - if (available) { - if (available.active) { - console.error( - "Cannot override an existing store. Make sure that stores are only created once." - ); - } else { - available.value.setState(initialState, true); - } - - available.active = true; - return available.value; - } else { - const store = createStore()(() => initialState); - initialStates[name] = initialState; + // We ignore whether there's already a store with this name so that tests + // don't have to worry about clearing old stores before re-creating them. + const store = createStore()(() => initialState); + initialStates[name] = initialState; - availableStores[name] = { - value: store, - active: true, - }; + availableStores[name] = { + value: store, + active: true, + }; - return instrumentedStore(name, store); - } + return instrumentedStore(name, store); } export function getGlobalStore(