redux-mock-store

Testing Redux Thunk Action Creator

左心房为你撑大大i 提交于 2020-01-06 02:53:07
问题 I've got a redux action creator that utilizes redux-thunk to do some logic to determine what to dispatch to the store. Its not promise-based, like an HTTP request would be, so I am having some issues with how to test it properly. Ill need a test for when the value meets the condition and for when it doesn't. Since the action creator does not return a promise, I cannot run a .then() in my test. What is the best way to test something like this? Likewise, I believe it would be pretty

Testing React Redux - cannot read properties of undefined, or wrapper undefined

佐手、 提交于 2019-12-14 01:30:03
问题 Im having a bit of a problem setting up a Redux store in my component for my test suite. The problem is that even if I try a unconnected mount then the test throws errors looking for variables in authState. I have the following component: import React, { Component } from 'react'; import { Link, Redirect } from "react-router-dom"; import {bindActionCreators} from 'redux'; import {connect} from 'react-redux'; import * as authActions from '../../../actions/auth.actions'; export class

Testing Async Redux Action Jest

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-08 05:48:26
问题 I'm having trouble getting the correct output from an async redux action. I am using Jest, redux-mock-adapter, and thunk as the tools. According to redux's documentation on testing async thunks (https://redux.js.org/docs/recipes/WritingTests.html#async-action-creators), my tests should be returning an array of two actions. However, my test is only returning the first action, and not the second one that should return on a successful fetch. I think I'm just missing something small here, but it

Testing Async Redux Action Jest

不羁的心 提交于 2019-12-06 15:50:01
I'm having trouble getting the correct output from an async redux action. I am using Jest, redux-mock-adapter, and thunk as the tools. According to redux's documentation on testing async thunks ( https://redux.js.org/docs/recipes/WritingTests.html#async-action-creators ), my tests should be returning an array of two actions. However, my test is only returning the first action, and not the second one that should return on a successful fetch. I think I'm just missing something small here, but it has been bothersome to say the least. Redux Action export const getRemoveFileMetrics = cacheKey =>

Cannot read property '.then' of undefined when testing async action creators with redux and react

≯℡__Kan透↙ 提交于 2019-11-30 17:17:28
I'm trying to write some test using react, redux-mock-store and redux, but I keep getting and error. Maybe because my Promise has not yet been resolved? The fetchListing() action creator actually works when I try it on dev and production, but I'm having problems making the test pass. error message (node:19143) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 3): SyntaxError (node:19143) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero

Cannot read property '.then' of undefined when testing async action creators with redux and react

六月ゝ 毕业季﹏ 提交于 2019-11-30 00:48:54
问题 I'm trying to write some test using react, redux-mock-store and redux, but I keep getting and error. Maybe because my Promise has not yet been resolved? The fetchListing() action creator actually works when I try it on dev and production, but I'm having problems making the test pass. error message (node:19143) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 3): SyntaxError (node:19143) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In