-
Notifications
You must be signed in to change notification settings - Fork 293
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
Problem with imports in tests #319
Comments
I'm not used to test containers and I have no idea of what's happening from the logs. It seems to be an error from Anyway, the way you are creating containers could lead to problems (and perhaps it's the cause of your current problem). Please, take a look on this: #131 (comment) |
@diegohaz I made changes to mapDispatchToProps export const mapDispatchToProps = (dispatch) => ({
addTodoRequest: (text) => dispatch(addTodoRequest(text))
}) And changed test: import {mapDispatchToProps} from '../AddTodoContainer';
it('mapDispatchToProps test', () => {
const text = 'test'
const dispatchSpy = jest.fn()
mapDispatchToProps(dispatchSpy).addTodoRequest(text)
expect(dispatchSpy.mock.calls).toEqual( [ [ { type: 'DEFAULT_ADD_TODO_REQUEST' } ] ])
}) But still encountered an error: FAIL src/containers/__tests__/AddTodoContainer.test.js
● mapDispatchToProps test
TypeError: (0 , _actions.addTodoRequest) is not a function
at Object.addTodoRequest (src/containers/AddTodoContainer.js:10:219)
at Object.<anonymous> (src/containers/__tests__/AddTodoContainer.test.js:16:60) Only changing ActionsMock.js made difference: module.exports = actions.default And then test passes. Also jest coverage makes warning about actionsMock (before and after small 'fix') Maybe is there a way to enable default import in tests? ps. I don't know how mapDispatchToProps can be wrapped like in your comment you've linked. |
I didn't wrap |
Hi, i'm not any good in creating issues and probably i'm doing it wrong and wrong place. But i'm trying 3rd day in a row and have no other options. Can't understand what is wrong and help will be appreciated.
I have contianer:
And test for it
The text was updated successfully, but these errors were encountered: