MCPcopy Index your code
hub / github.com/continuedev/continue / createMockStore

Function createMockStore

gui/src/util/test/mockStore.ts:53–114  ·  view source on GitHub ↗
(
  initialState?: Partial<RootState>,
  mockMessenger?: MockIdeMessenger,
)

Source from the content-addressed store, hash-verified

51};
52
53export const createMockStore = (
54 initialState?: Partial<RootState>,
55 mockMessenger?: MockIdeMessenger,
56): ReturnType<typeof configureStore> & {
57 mockIdeMessenger: MockIdeMessenger;
58 getActions: () => any[];
59 clearActions: () => void;
60} => {
61 const mockIdeMessenger = mockMessenger ?? new MockIdeMessenger();
62
63 const store = configureStore({
64 reducer: {
65 session: sessionReducer,
66 ui: uiReducer,
67 editModeState: editModeStateReducer,
68 config: configReducer,
69 indexing: indexingReducer,
70 tabs: tabsReducer,
71 profiles: profilesReducer,
72 },
73 preloadedState: {
74 ...getEmptyRootState(),
75 ...initialState,
76 },
77 middleware: (getDefaultMiddleware) =>
78 getDefaultMiddleware({
79 serializableCheck: {
80 ignoredPaths: ["session.streamAborter", "ui.dialogMessage"],
81 ignoredActions: ["ui/setDialogMessage"],
82 },
83 thunk: {
84 extraArgument: {
85 ideMessenger: mockIdeMessenger,
86 },
87 },
88 }),
89 });
90
91 // Add getActions method for testing
92 const actions: any[] = [];
93 const originalDispatch = store.dispatch;
94
95 // Override dispatch to track actions and inject ideMessenger
96 store.dispatch = vi.fn((action: any) => {
97 if (typeof action === "function") {
98 // For thunks, provide the extra argument with ideMessenger
99 return action(store.dispatch, store.getState, {
100 ideMessenger: mockIdeMessenger,
101 });
102 }
103 actions.push(action);
104 return originalDispatch(action);
105 });
106
107 // Expose mockIdeMessenger so tests can configure it
108 return {
109 ...store,
110 mockIdeMessenger,

Calls 2

getEmptyRootStateFunction · 0.85
pushMethod · 0.65

Tested by 2

renderComponentFunction · 0.72
renderComponentFunction · 0.72