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

configureStore is not a function via module.exports #159

Open
Kronenberg opened this issue Oct 10, 2018 · 14 comments
Open

configureStore is not a function via module.exports #159

Kronenberg opened this issue Oct 10, 2018 · 14 comments

Comments

@Kronenberg
Copy link

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?

@newyork-anthonyng
Copy link
Contributor

The README.md says to use the below:

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

@Kronenberg
Copy link
Author

Kronenberg commented Oct 10, 2018

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

@newyork-anthonyng
Copy link
Contributor

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

@Kronenberg
Copy link
Author

Kronenberg commented Oct 15, 2018

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

@MaxLarue
Copy link

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

@newyork-anthonyng
Copy link
Contributor

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

@jednano
Copy link

jednano commented Jul 12, 2019

This should be fixed in my TypeScript fork: #148 (comment)

@abdul-hamid-achik
Copy link

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

@jednano
Copy link

jednano commented Aug 11, 2019

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

@abdul-hamid-achik
Copy link

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

@jednano
Copy link

jednano commented Aug 13, 2019

I have it working with Jest here, FWIW.

@abdul-hamid-achik
Copy link

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
Copy link

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

@happysmilecode
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants