redux-mock-store icon indicating copy to clipboard operation
redux-mock-store copied to clipboard

configureStore is not a function via module.exports

Open Kronenberg opened this issue 5 years ago • 14 comments

Here is my example screen shot 2018-10-10 at 11 53 03

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?

Kronenberg avatar Oct 10 '18 08:10 Kronenberg

The README.md says to use the below:

const { configureStore } = require('redux-mock-store');

newyork-anthonyng avatar Oct 10 '18 10:10 newyork-anthonyng

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 screen shot 2018-10-10 at 13 43 46 , but i have another error like: mockStore is not a function screen shot 2018-10-10 at 13 44 16

Kronenberg avatar Oct 10 '18 10:10 Kronenberg

Can you create a repository that recreates a basic example of this error?

newyork-anthonyng avatar Oct 10 '18 23:10 newyork-anthonyng

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

Kronenberg avatar Oct 15 '18 13:10 Kronenberg

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

MaxLarue avatar Nov 19 '18 11:11 MaxLarue

@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.

newyork-anthonyng avatar Nov 20 '18 13:11 newyork-anthonyng

This should be fixed in my TypeScript fork: https://github.com/dmitry-zaets/redux-mock-store/issues/148#issuecomment-510758916

jednano avatar Jul 12 '19 06:07 jednano

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

abdul-hamid-achik avatar Aug 10 '19 22:08 abdul-hamid-achik

Try import configureStore from "@jedmao/redux-mock-store; (installation required).

jednano avatar Aug 11 '19 04:08 jednano

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 :(

abdul-hamid-achik avatar Aug 13 '19 02:08 abdul-hamid-achik

I have it working with Jest here, FWIW.

jednano avatar Aug 13 '19 05:08 jednano

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

abdul-hamid-achik avatar Aug 15 '19 04:08 abdul-hamid-achik

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 imagen

abdul-hamid-achik avatar Aug 15 '19 06:08 abdul-hamid-achik

Please leave your jest config file in more detail. I have still error. Thanks.

happysmilecode avatar Apr 17 '23 11:04 happysmilecode