Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImmutableStateInvariantMiddleware affecting tests in dev environment (#23) #219

Merged
merged 4 commits into from
Jun 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions src/app/state/store.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,20 @@ export const middleware: Middleware[] = [
userConsistencyCheckerMiddleware,
notificationCheckerMiddleware,
];
const defaultMiddlewareOptions = {
serializableCheck: process.env.NODE_ENV !== "test",
};

export const store = configureStore({
reducer: rootReducer,
// [thunk, immutableStateInvariant, serializableStateInvariant] are all in the default middleware and included by default
// in development, with only thunk included in production.
// See https://redux-toolkit.js.org/api/getDefaultMiddleware#customizing-the-included-middleware
middleware: (getDefaultMiddleware) => {
const newMiddleware = getDefaultMiddleware(defaultMiddlewareOptions).concat(middleware);
const newMiddleware = getDefaultMiddleware({
immutableCheck: false,
serializableCheck: process.env.NODE_ENV !== "test",
}).concat(middleware);

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
if (process.env.NODE_ENV !== "production" && !window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__) {
newMiddleware.concat([reduxLogger]);
}

return newMiddleware;
},
preloadedState: {},
Expand Down
Loading