redux-mock-store
redux-mock-store copied to clipboard
configureStore is not a function via module.exports
Here is my example
I am try to require and run this module but have error: TypeError: configureStore is not a function With regular import configureStore from 'redux-mock-store' everything works fine. But i can't use imports in any case. Can somebody help me with that?
The README.md
says to use the below:
const { configureStore } = require('redux-mock-store');
The
README.md
says to use the below:const { configureStore } = require('redux-mock-store');
I am already try this thing. Its not working.
I am try with default
, but i have another error like: mockStore is not a function
Can you create a repository that recreates a basic example of this error?
Can you create a repository that recreates a basic example of this error?
Link: https://github.com/Kronenberg/redux-thunk-tests-example source for example test: src/actions/PlaceHolderApiActions.test.js
Did you try
const configureStore = require('redux-mock-store').configureStore
?
or
const redux_mock_store = require("redux-mock-store")
const configureStore = redux_mock_store.configureStore
Let me knwo ig that worked
@Kronenberg Sorry for late response.
It looks like you have a typo in your code.
// 👇 this works for you
import configureMockStore from "redux-mock-store";
// 👇 notice how you named this import "configureStore", rather than "configureMockStore"
const configureStore = require('redux-mock-store').default();
I changed the below and it worked.
- const configureStore = require('redux-mock-store').default();
+ const configureMockStore = require('redux-mock-store').default;
I changed the import name from configureStore
to configureMockStore
, and changed default()
to default
.
This should be fixed in my TypeScript fork: https://github.com/dmitry-zaets/redux-mock-store/issues/148#issuecomment-510758916
still not working, im using version 1.5.3
whenever i use it as:
import configureStore from 'redux-mock-store'
i get TypeError: (0 , _reduxMockStore.default) is not a function
Try import configureStore from "@jedmao/redux-mock-store;
(installation required).
same problem, at this point i think it has something to do with jest and the way i have it configured, do you think i should add this lib to the trransformIgnorePatterns? if i open node and import it manually it works flawlesly but not with jest :(
I have it working with Jest here, FWIW.
same issue, its not working for me, at this point it could really be my setup because no matter how i change the redux-mock-store library, it keep getting the same error
Okay guys sorry for the problems, it was infact a problem on my end, decided to redo the part and got rid of manually mapping my project dependencies for jest and this just went back to work normally, started using @
as a namespace for my modules...
thanks for the help, ill leave the screenshot in case someone comes and has the same problem as me, its most likely your jest.config.json
config at this point
Please leave your jest config file in more detail. I have still error. Thanks.