Skip to content

Zustand testing throws an error "TypeError: store.getState is not a function" #905

Closed
@Boniqx

Description

In the documentation it states that adding this in JEST would enable testing for ZUSTAND state.

const create = createState => {
  const store = actualCreate(createState);
  const initialState = store.getState();
  storeResetFns.add(() => store.setState(initialState, true));
  return store;
};

But it seems to throw an error "TypeError: store.getState is not a function"

I am using typescript not sure if this causes some issues. Also, it is not well documented on how to use this test in jest. Just want to have values on my states so that they can be used on my componentes during rendering of test components.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions