Unable to access react modal component jsx when exported with Redux The Next CEO of Stack OverflowReact JSX: Access Props in QuotesLoop inside React JSXcall function after react-router-redux pushCreate modal in react-redux using stateless functional componentsReactjs refresh parent after react modal popup changes dataReact prevent from toggle multiple modalsHow do I test component methods on a React component that are defined as arrow functions (class properties)?(React) How do you pass in functions to components that are wrapped in a variable?Mocking a React component function that is enclosed by Redux Provider componentHow to unit test the output of a React component method in a React Router / Redux app with Enzyme
Would this house-rule that treats advantage as a +1 to the roll instead (and disadvantage as -1) and allows them to stack be balanced?
How many extra stops do monopods offer for tele photographs?
Why this way of making earth uninhabitable in Interstellar?
Why, when going from special to general relativity, do we just replace partial derivatives with covariant derivatives?
Is there a difference between "Fahrstuhl" and "Aufzug"
Why isn't acceleration always zero whenever velocity is zero, such as the moment a ball bounces off a wall?
Can MTA send mail via a relay without being told so?
What happened in Rome, when the western empire "fell"?
What does "Its cash flow is deeply negative" mean?
Solving system of ODEs with extra parameter
Is it okay to majorly distort historical facts while writing a fiction story?
Is wanting to ask what to write an indication that you need to change your story?
Does it make sense to invest money on space investigation?
WOW air has ceased operation, can I get my tickets refunded?
Proper way to express "He disappeared them"
Flying from Cape Town to England and return to another province
Powershell. How to parse gci Name?
Does soap repel water?
Make solar eclipses exceedingly rare, but still have new moons
Newlines in BSD sed vs gsed
What flight has the highest ratio of time difference to flight time?
Is it ever safe to open a suspicious HTML file (e.g. email attachment)?
Running a General Election and the European Elections together
Why doesn't UK go for the same deal Japan has with EU to resolve Brexit?
Unable to access react modal component jsx when exported with Redux
The Next CEO of Stack OverflowReact JSX: Access Props in QuotesLoop inside React JSXcall function after react-router-redux pushCreate modal in react-redux using stateless functional componentsReactjs refresh parent after react modal popup changes dataReact prevent from toggle multiple modalsHow do I test component methods on a React component that are defined as arrow functions (class properties)?(React) How do you pass in functions to components that are wrapped in a variable?Mocking a React component function that is enclosed by Redux Provider componentHow to unit test the output of a React component method in a React Router / Redux app with Enzyme
I have a test for a React component which is being exported with connect. I was able to have my tests pass, but my Snapsnot is not what I expect it to be. I opened a GH issue with the enzyme team as well Note I took out some of the methods, since they are not applicable to the issue.
My Component
import React, Component from 'react';
import PropTypes from 'prop-types'
import bindActionCreators from 'redux';
import connect from 'react-redux';
import withStyles from 'isomorphic-style-loader/lib/withStyles';
import get from 'lodash/get';
import isArray from 'lodash/isArray';
import isString from '../../helpers/typeCheckHelper';
import classNames from 'classnames';
import * as actionCreators from '../../actions/modal';
import GenericModal from '../GenericModal';
import Notify from '../../components/Notify';
import s from './AnalyzeModal.scss';
export class AnalyzeModal extends Component
static propTypes =
data: PropTypes.object,
sendData: PropTypes.func,
isOpen: PropTypes.bool,
openModal: PropTypes.func,
closeModal: PropTypes.func,
customStyles: PropTypes.object,
wasClicked: PropTypes.bool,
isSpinner: PropTypes.bool,
toggleSpinner: PropTypes.func,
handleAnalyzeListOfBonds: PropTypes.func,
id: PropTypes.string,
constructor(props)
super(props);
this.state =
notes: '',
;
this.closeModal = this.closeModal.bind(this);
this.handleNotesChange = this.handleNotesChange.bind(this);
render()
const isOpen, customStyles, wasClicked, isSpinner, id = this.props;
return (
<GenericModal
isOpen=isOpen
style=customStyles
contentLabel="List/Portfolio Review"
>
<div className=classNames('buy-btn-modal row', s['analyze-modal'])>
<h1 className="column small-11 header">Portfolio Review</h1>
<button
className="column small-1 close-modal"
data-id=`$MODAL-close-button`
onClick=() => this.closeModal();
>X</button>
<div className="column small-12">
<div className=classNames('column small-12', s['table-container'], s['force-show-scrollbar'])>
<div className=classNames('row', s['table-header'])>
<div className=classNames('columns small-3 text-left', s['table-header-label'])>QUANTITY</div>
</div>
this.renderTableData()
</div>
<div className="column small-12 field-container">
<label
className="label column small-3 text-right"
htmlFor="notes"
>NOTES</label>
<textarea
className=classNames('notes-field', s['notes-field'])
data-id=`$MODAL-form-notes`
onChange=this.handleNotesChange
/>
</div>
<div className="column small-12 button-wrapper">
<button
className=classNames('small-4 bright-blue submit-btn', s['submit-btn'])
data-id=`$MODAL-submit-button`
onClick=() => this.handleSubmit();
disabled=!!wasClicked
>
isSpinner ?
<div className="spinner-full-page modal-spinner" /> :
'Submit'
</button>
<button
className=classNames('small-4 bright-blue cancel-btn', s['cancel-btn'])
onClick=() => this.closeModal();
>Cancel</button>
</div>
</div>
</div>
</GenericModal>
);
const mapDispatchToProps = dispatch => (
bindActionCreators(actionCreators, dispatch)
);
const mapStateToProps = state => (
isOpen: state.modal.isModalOpen,
id: state.modal.id,
wasClicked: state.modal.wasClicked,
isSpinner: state.modal.isSpinner,
data: state.modal.data,
);
export default withStyles(s)(connect(mapStateToProps, mapDispatchToProps)(AnalyzeModal));
My Test
import React from 'react';
import AnalyzeModal from '../components/AnalyzeModal';
import Link from '../components/Link';
import render, mount, shallow from 'enzyme';
import thunk from 'redux-thunk';
import configureMockStore from 'redux-mock-store';
describe('<Analyze />', () =>
// create any initial state needed to render Connected component
const initialState =
modal:
isModalOpen: false,
id: '',
wasClicked: false,
isMarkIncluded: false,
isSpinner: false,
isOpen: null,
openModal: null,
closeModal: null,
data: null,
,
;
const middlewares = [thunk];
const mockStore = configureMockStore(middlewares);
let wrapper;
let store;
beforeEach(() =>
store = mockStore(initialState);
wrapper = mount(<AnalyzeModal store=store />);
);
test('should be defined', () =>
expect(wrapper).toBeDefined();
);
test('matches the snapshot', () =>
expect(wrapper).toMatchSnapshot();
)
);
My Test Snapshot
// Jest Snapshot v1
exports[`<Analyze /> matches the snapshot 1`] = `
<Connect(AnalyzeModal)
store=
Object
"clearActions": [Function],
"dispatch": [Function],
"getActions": [Function],
"getState": [Function],
"replaceReducer": [Function],
"subscribe": [Function],
>
<AnalyzeModal
closeModal=[Function]
data=null
id=""
isOpen=false
isSpinner=false
openModal=[Function]
sendData=[Function]
store=
Object
"clearActions": [Function],
"dispatch": [Function],
"getActions": [Function],
"getState": [Function],
"replaceReducer": [Function],
"subscribe": [Function],
toggleMark=[Function]
toggleSpinner=[Function]
wasClicked=false
/>
</Connect(AnalyzeModal)>
Current behavior
Currently, the snapshot is returning the component without the JSX inside of the component itself.
Expected behavior
I expect the component to container jsx elements such as: button, div, etc.
My environment:
Version
library | version
enzyme | "^3.9.0"
react | "^15.3.1"
react-dom | "^15.3.1"
react-test-renderer | "^15.3.1"
adapter (enzyme-adapter-react-15.4) | "^1.3.1"
reactjs redux jestjs enzyme react-modal
add a comment |
I have a test for a React component which is being exported with connect. I was able to have my tests pass, but my Snapsnot is not what I expect it to be. I opened a GH issue with the enzyme team as well Note I took out some of the methods, since they are not applicable to the issue.
My Component
import React, Component from 'react';
import PropTypes from 'prop-types'
import bindActionCreators from 'redux';
import connect from 'react-redux';
import withStyles from 'isomorphic-style-loader/lib/withStyles';
import get from 'lodash/get';
import isArray from 'lodash/isArray';
import isString from '../../helpers/typeCheckHelper';
import classNames from 'classnames';
import * as actionCreators from '../../actions/modal';
import GenericModal from '../GenericModal';
import Notify from '../../components/Notify';
import s from './AnalyzeModal.scss';
export class AnalyzeModal extends Component
static propTypes =
data: PropTypes.object,
sendData: PropTypes.func,
isOpen: PropTypes.bool,
openModal: PropTypes.func,
closeModal: PropTypes.func,
customStyles: PropTypes.object,
wasClicked: PropTypes.bool,
isSpinner: PropTypes.bool,
toggleSpinner: PropTypes.func,
handleAnalyzeListOfBonds: PropTypes.func,
id: PropTypes.string,
constructor(props)
super(props);
this.state =
notes: '',
;
this.closeModal = this.closeModal.bind(this);
this.handleNotesChange = this.handleNotesChange.bind(this);
render()
const isOpen, customStyles, wasClicked, isSpinner, id = this.props;
return (
<GenericModal
isOpen=isOpen
style=customStyles
contentLabel="List/Portfolio Review"
>
<div className=classNames('buy-btn-modal row', s['analyze-modal'])>
<h1 className="column small-11 header">Portfolio Review</h1>
<button
className="column small-1 close-modal"
data-id=`$MODAL-close-button`
onClick=() => this.closeModal();
>X</button>
<div className="column small-12">
<div className=classNames('column small-12', s['table-container'], s['force-show-scrollbar'])>
<div className=classNames('row', s['table-header'])>
<div className=classNames('columns small-3 text-left', s['table-header-label'])>QUANTITY</div>
</div>
this.renderTableData()
</div>
<div className="column small-12 field-container">
<label
className="label column small-3 text-right"
htmlFor="notes"
>NOTES</label>
<textarea
className=classNames('notes-field', s['notes-field'])
data-id=`$MODAL-form-notes`
onChange=this.handleNotesChange
/>
</div>
<div className="column small-12 button-wrapper">
<button
className=classNames('small-4 bright-blue submit-btn', s['submit-btn'])
data-id=`$MODAL-submit-button`
onClick=() => this.handleSubmit();
disabled=!!wasClicked
>
isSpinner ?
<div className="spinner-full-page modal-spinner" /> :
'Submit'
</button>
<button
className=classNames('small-4 bright-blue cancel-btn', s['cancel-btn'])
onClick=() => this.closeModal();
>Cancel</button>
</div>
</div>
</div>
</GenericModal>
);
const mapDispatchToProps = dispatch => (
bindActionCreators(actionCreators, dispatch)
);
const mapStateToProps = state => (
isOpen: state.modal.isModalOpen,
id: state.modal.id,
wasClicked: state.modal.wasClicked,
isSpinner: state.modal.isSpinner,
data: state.modal.data,
);
export default withStyles(s)(connect(mapStateToProps, mapDispatchToProps)(AnalyzeModal));
My Test
import React from 'react';
import AnalyzeModal from '../components/AnalyzeModal';
import Link from '../components/Link';
import render, mount, shallow from 'enzyme';
import thunk from 'redux-thunk';
import configureMockStore from 'redux-mock-store';
describe('<Analyze />', () =>
// create any initial state needed to render Connected component
const initialState =
modal:
isModalOpen: false,
id: '',
wasClicked: false,
isMarkIncluded: false,
isSpinner: false,
isOpen: null,
openModal: null,
closeModal: null,
data: null,
,
;
const middlewares = [thunk];
const mockStore = configureMockStore(middlewares);
let wrapper;
let store;
beforeEach(() =>
store = mockStore(initialState);
wrapper = mount(<AnalyzeModal store=store />);
);
test('should be defined', () =>
expect(wrapper).toBeDefined();
);
test('matches the snapshot', () =>
expect(wrapper).toMatchSnapshot();
)
);
My Test Snapshot
// Jest Snapshot v1
exports[`<Analyze /> matches the snapshot 1`] = `
<Connect(AnalyzeModal)
store=
Object
"clearActions": [Function],
"dispatch": [Function],
"getActions": [Function],
"getState": [Function],
"replaceReducer": [Function],
"subscribe": [Function],
>
<AnalyzeModal
closeModal=[Function]
data=null
id=""
isOpen=false
isSpinner=false
openModal=[Function]
sendData=[Function]
store=
Object
"clearActions": [Function],
"dispatch": [Function],
"getActions": [Function],
"getState": [Function],
"replaceReducer": [Function],
"subscribe": [Function],
toggleMark=[Function]
toggleSpinner=[Function]
wasClicked=false
/>
</Connect(AnalyzeModal)>
Current behavior
Currently, the snapshot is returning the component without the JSX inside of the component itself.
Expected behavior
I expect the component to container jsx elements such as: button, div, etc.
My environment:
Version
library | version
enzyme | "^3.9.0"
react | "^15.3.1"
react-dom | "^15.3.1"
react-test-renderer | "^15.3.1"
adapter (enzyme-adapter-react-15.4) | "^1.3.1"
reactjs redux jestjs enzyme react-modal
DoesGenericModal
not render anything if itsisOpen
prop isfalse
? (that would be my guess without being able to actually run and test anything)
– brian-lives-outdoors
Mar 21 at 22:24
It does not, so I tried two things: first, changing myinitialState
object to haveisOpen
set totrue
. second, performing asetProps
in my first test case:wrapper.setProps( isOpen: true )
. When Iconsole.log(wrapper)
, it returns:ReactWrapper
– eagercoder
Mar 22 at 0:16
@brian-lives-outdoors, I think this is a good starting point. Meaning the issue, is likely related to the modal not being open. I may need to usesinon
to spy on theopenModal
method in my reducer, to trigger the opening of the modal, but that seems like overlike. Thoughts?
– eagercoder
Mar 22 at 0:18
@brian-lives-outdoors, settingisOpen
to false, didn't fix it. Any other ideas?
– eagercoder
Mar 25 at 19:31
add a comment |
I have a test for a React component which is being exported with connect. I was able to have my tests pass, but my Snapsnot is not what I expect it to be. I opened a GH issue with the enzyme team as well Note I took out some of the methods, since they are not applicable to the issue.
My Component
import React, Component from 'react';
import PropTypes from 'prop-types'
import bindActionCreators from 'redux';
import connect from 'react-redux';
import withStyles from 'isomorphic-style-loader/lib/withStyles';
import get from 'lodash/get';
import isArray from 'lodash/isArray';
import isString from '../../helpers/typeCheckHelper';
import classNames from 'classnames';
import * as actionCreators from '../../actions/modal';
import GenericModal from '../GenericModal';
import Notify from '../../components/Notify';
import s from './AnalyzeModal.scss';
export class AnalyzeModal extends Component
static propTypes =
data: PropTypes.object,
sendData: PropTypes.func,
isOpen: PropTypes.bool,
openModal: PropTypes.func,
closeModal: PropTypes.func,
customStyles: PropTypes.object,
wasClicked: PropTypes.bool,
isSpinner: PropTypes.bool,
toggleSpinner: PropTypes.func,
handleAnalyzeListOfBonds: PropTypes.func,
id: PropTypes.string,
constructor(props)
super(props);
this.state =
notes: '',
;
this.closeModal = this.closeModal.bind(this);
this.handleNotesChange = this.handleNotesChange.bind(this);
render()
const isOpen, customStyles, wasClicked, isSpinner, id = this.props;
return (
<GenericModal
isOpen=isOpen
style=customStyles
contentLabel="List/Portfolio Review"
>
<div className=classNames('buy-btn-modal row', s['analyze-modal'])>
<h1 className="column small-11 header">Portfolio Review</h1>
<button
className="column small-1 close-modal"
data-id=`$MODAL-close-button`
onClick=() => this.closeModal();
>X</button>
<div className="column small-12">
<div className=classNames('column small-12', s['table-container'], s['force-show-scrollbar'])>
<div className=classNames('row', s['table-header'])>
<div className=classNames('columns small-3 text-left', s['table-header-label'])>QUANTITY</div>
</div>
this.renderTableData()
</div>
<div className="column small-12 field-container">
<label
className="label column small-3 text-right"
htmlFor="notes"
>NOTES</label>
<textarea
className=classNames('notes-field', s['notes-field'])
data-id=`$MODAL-form-notes`
onChange=this.handleNotesChange
/>
</div>
<div className="column small-12 button-wrapper">
<button
className=classNames('small-4 bright-blue submit-btn', s['submit-btn'])
data-id=`$MODAL-submit-button`
onClick=() => this.handleSubmit();
disabled=!!wasClicked
>
isSpinner ?
<div className="spinner-full-page modal-spinner" /> :
'Submit'
</button>
<button
className=classNames('small-4 bright-blue cancel-btn', s['cancel-btn'])
onClick=() => this.closeModal();
>Cancel</button>
</div>
</div>
</div>
</GenericModal>
);
const mapDispatchToProps = dispatch => (
bindActionCreators(actionCreators, dispatch)
);
const mapStateToProps = state => (
isOpen: state.modal.isModalOpen,
id: state.modal.id,
wasClicked: state.modal.wasClicked,
isSpinner: state.modal.isSpinner,
data: state.modal.data,
);
export default withStyles(s)(connect(mapStateToProps, mapDispatchToProps)(AnalyzeModal));
My Test
import React from 'react';
import AnalyzeModal from '../components/AnalyzeModal';
import Link from '../components/Link';
import render, mount, shallow from 'enzyme';
import thunk from 'redux-thunk';
import configureMockStore from 'redux-mock-store';
describe('<Analyze />', () =>
// create any initial state needed to render Connected component
const initialState =
modal:
isModalOpen: false,
id: '',
wasClicked: false,
isMarkIncluded: false,
isSpinner: false,
isOpen: null,
openModal: null,
closeModal: null,
data: null,
,
;
const middlewares = [thunk];
const mockStore = configureMockStore(middlewares);
let wrapper;
let store;
beforeEach(() =>
store = mockStore(initialState);
wrapper = mount(<AnalyzeModal store=store />);
);
test('should be defined', () =>
expect(wrapper).toBeDefined();
);
test('matches the snapshot', () =>
expect(wrapper).toMatchSnapshot();
)
);
My Test Snapshot
// Jest Snapshot v1
exports[`<Analyze /> matches the snapshot 1`] = `
<Connect(AnalyzeModal)
store=
Object
"clearActions": [Function],
"dispatch": [Function],
"getActions": [Function],
"getState": [Function],
"replaceReducer": [Function],
"subscribe": [Function],
>
<AnalyzeModal
closeModal=[Function]
data=null
id=""
isOpen=false
isSpinner=false
openModal=[Function]
sendData=[Function]
store=
Object
"clearActions": [Function],
"dispatch": [Function],
"getActions": [Function],
"getState": [Function],
"replaceReducer": [Function],
"subscribe": [Function],
toggleMark=[Function]
toggleSpinner=[Function]
wasClicked=false
/>
</Connect(AnalyzeModal)>
Current behavior
Currently, the snapshot is returning the component without the JSX inside of the component itself.
Expected behavior
I expect the component to container jsx elements such as: button, div, etc.
My environment:
Version
library | version
enzyme | "^3.9.0"
react | "^15.3.1"
react-dom | "^15.3.1"
react-test-renderer | "^15.3.1"
adapter (enzyme-adapter-react-15.4) | "^1.3.1"
reactjs redux jestjs enzyme react-modal
I have a test for a React component which is being exported with connect. I was able to have my tests pass, but my Snapsnot is not what I expect it to be. I opened a GH issue with the enzyme team as well Note I took out some of the methods, since they are not applicable to the issue.
My Component
import React, Component from 'react';
import PropTypes from 'prop-types'
import bindActionCreators from 'redux';
import connect from 'react-redux';
import withStyles from 'isomorphic-style-loader/lib/withStyles';
import get from 'lodash/get';
import isArray from 'lodash/isArray';
import isString from '../../helpers/typeCheckHelper';
import classNames from 'classnames';
import * as actionCreators from '../../actions/modal';
import GenericModal from '../GenericModal';
import Notify from '../../components/Notify';
import s from './AnalyzeModal.scss';
export class AnalyzeModal extends Component
static propTypes =
data: PropTypes.object,
sendData: PropTypes.func,
isOpen: PropTypes.bool,
openModal: PropTypes.func,
closeModal: PropTypes.func,
customStyles: PropTypes.object,
wasClicked: PropTypes.bool,
isSpinner: PropTypes.bool,
toggleSpinner: PropTypes.func,
handleAnalyzeListOfBonds: PropTypes.func,
id: PropTypes.string,
constructor(props)
super(props);
this.state =
notes: '',
;
this.closeModal = this.closeModal.bind(this);
this.handleNotesChange = this.handleNotesChange.bind(this);
render()
const isOpen, customStyles, wasClicked, isSpinner, id = this.props;
return (
<GenericModal
isOpen=isOpen
style=customStyles
contentLabel="List/Portfolio Review"
>
<div className=classNames('buy-btn-modal row', s['analyze-modal'])>
<h1 className="column small-11 header">Portfolio Review</h1>
<button
className="column small-1 close-modal"
data-id=`$MODAL-close-button`
onClick=() => this.closeModal();
>X</button>
<div className="column small-12">
<div className=classNames('column small-12', s['table-container'], s['force-show-scrollbar'])>
<div className=classNames('row', s['table-header'])>
<div className=classNames('columns small-3 text-left', s['table-header-label'])>QUANTITY</div>
</div>
this.renderTableData()
</div>
<div className="column small-12 field-container">
<label
className="label column small-3 text-right"
htmlFor="notes"
>NOTES</label>
<textarea
className=classNames('notes-field', s['notes-field'])
data-id=`$MODAL-form-notes`
onChange=this.handleNotesChange
/>
</div>
<div className="column small-12 button-wrapper">
<button
className=classNames('small-4 bright-blue submit-btn', s['submit-btn'])
data-id=`$MODAL-submit-button`
onClick=() => this.handleSubmit();
disabled=!!wasClicked
>
isSpinner ?
<div className="spinner-full-page modal-spinner" /> :
'Submit'
</button>
<button
className=classNames('small-4 bright-blue cancel-btn', s['cancel-btn'])
onClick=() => this.closeModal();
>Cancel</button>
</div>
</div>
</div>
</GenericModal>
);
const mapDispatchToProps = dispatch => (
bindActionCreators(actionCreators, dispatch)
);
const mapStateToProps = state => (
isOpen: state.modal.isModalOpen,
id: state.modal.id,
wasClicked: state.modal.wasClicked,
isSpinner: state.modal.isSpinner,
data: state.modal.data,
);
export default withStyles(s)(connect(mapStateToProps, mapDispatchToProps)(AnalyzeModal));
My Test
import React from 'react';
import AnalyzeModal from '../components/AnalyzeModal';
import Link from '../components/Link';
import render, mount, shallow from 'enzyme';
import thunk from 'redux-thunk';
import configureMockStore from 'redux-mock-store';
describe('<Analyze />', () =>
// create any initial state needed to render Connected component
const initialState =
modal:
isModalOpen: false,
id: '',
wasClicked: false,
isMarkIncluded: false,
isSpinner: false,
isOpen: null,
openModal: null,
closeModal: null,
data: null,
,
;
const middlewares = [thunk];
const mockStore = configureMockStore(middlewares);
let wrapper;
let store;
beforeEach(() =>
store = mockStore(initialState);
wrapper = mount(<AnalyzeModal store=store />);
);
test('should be defined', () =>
expect(wrapper).toBeDefined();
);
test('matches the snapshot', () =>
expect(wrapper).toMatchSnapshot();
)
);
My Test Snapshot
// Jest Snapshot v1
exports[`<Analyze /> matches the snapshot 1`] = `
<Connect(AnalyzeModal)
store=
Object
"clearActions": [Function],
"dispatch": [Function],
"getActions": [Function],
"getState": [Function],
"replaceReducer": [Function],
"subscribe": [Function],
>
<AnalyzeModal
closeModal=[Function]
data=null
id=""
isOpen=false
isSpinner=false
openModal=[Function]
sendData=[Function]
store=
Object
"clearActions": [Function],
"dispatch": [Function],
"getActions": [Function],
"getState": [Function],
"replaceReducer": [Function],
"subscribe": [Function],
toggleMark=[Function]
toggleSpinner=[Function]
wasClicked=false
/>
</Connect(AnalyzeModal)>
Current behavior
Currently, the snapshot is returning the component without the JSX inside of the component itself.
Expected behavior
I expect the component to container jsx elements such as: button, div, etc.
My environment:
Version
library | version
enzyme | "^3.9.0"
react | "^15.3.1"
react-dom | "^15.3.1"
react-test-renderer | "^15.3.1"
adapter (enzyme-adapter-react-15.4) | "^1.3.1"
reactjs redux jestjs enzyme react-modal
reactjs redux jestjs enzyme react-modal
edited Mar 23 at 14:44
Şivā SankĂr
1,25411022
1,25411022
asked Mar 21 at 18:06
eagercodereagercoder
10213
10213
DoesGenericModal
not render anything if itsisOpen
prop isfalse
? (that would be my guess without being able to actually run and test anything)
– brian-lives-outdoors
Mar 21 at 22:24
It does not, so I tried two things: first, changing myinitialState
object to haveisOpen
set totrue
. second, performing asetProps
in my first test case:wrapper.setProps( isOpen: true )
. When Iconsole.log(wrapper)
, it returns:ReactWrapper
– eagercoder
Mar 22 at 0:16
@brian-lives-outdoors, I think this is a good starting point. Meaning the issue, is likely related to the modal not being open. I may need to usesinon
to spy on theopenModal
method in my reducer, to trigger the opening of the modal, but that seems like overlike. Thoughts?
– eagercoder
Mar 22 at 0:18
@brian-lives-outdoors, settingisOpen
to false, didn't fix it. Any other ideas?
– eagercoder
Mar 25 at 19:31
add a comment |
DoesGenericModal
not render anything if itsisOpen
prop isfalse
? (that would be my guess without being able to actually run and test anything)
– brian-lives-outdoors
Mar 21 at 22:24
It does not, so I tried two things: first, changing myinitialState
object to haveisOpen
set totrue
. second, performing asetProps
in my first test case:wrapper.setProps( isOpen: true )
. When Iconsole.log(wrapper)
, it returns:ReactWrapper
– eagercoder
Mar 22 at 0:16
@brian-lives-outdoors, I think this is a good starting point. Meaning the issue, is likely related to the modal not being open. I may need to usesinon
to spy on theopenModal
method in my reducer, to trigger the opening of the modal, but that seems like overlike. Thoughts?
– eagercoder
Mar 22 at 0:18
@brian-lives-outdoors, settingisOpen
to false, didn't fix it. Any other ideas?
– eagercoder
Mar 25 at 19:31
Does
GenericModal
not render anything if its isOpen
prop is false
? (that would be my guess without being able to actually run and test anything)– brian-lives-outdoors
Mar 21 at 22:24
Does
GenericModal
not render anything if its isOpen
prop is false
? (that would be my guess without being able to actually run and test anything)– brian-lives-outdoors
Mar 21 at 22:24
It does not, so I tried two things: first, changing my
initialState
object to have isOpen
set to true
. second, performing a setProps
in my first test case: wrapper.setProps( isOpen: true )
. When I console.log(wrapper)
, it returns: ReactWrapper
– eagercoder
Mar 22 at 0:16
It does not, so I tried two things: first, changing my
initialState
object to have isOpen
set to true
. second, performing a setProps
in my first test case: wrapper.setProps( isOpen: true )
. When I console.log(wrapper)
, it returns: ReactWrapper
– eagercoder
Mar 22 at 0:16
@brian-lives-outdoors, I think this is a good starting point. Meaning the issue, is likely related to the modal not being open. I may need to use
sinon
to spy on the openModal
method in my reducer, to trigger the opening of the modal, but that seems like overlike. Thoughts?– eagercoder
Mar 22 at 0:18
@brian-lives-outdoors, I think this is a good starting point. Meaning the issue, is likely related to the modal not being open. I may need to use
sinon
to spy on the openModal
method in my reducer, to trigger the opening of the modal, but that seems like overlike. Thoughts?– eagercoder
Mar 22 at 0:18
@brian-lives-outdoors, setting
isOpen
to false, didn't fix it. Any other ideas?– eagercoder
Mar 25 at 19:31
@brian-lives-outdoors, setting
isOpen
to false, didn't fix it. Any other ideas?– eagercoder
Mar 25 at 19:31
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55286687%2funable-to-access-react-modal-component-jsx-when-exported-with-redux%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55286687%2funable-to-access-react-modal-component-jsx-when-exported-with-redux%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Does
GenericModal
not render anything if itsisOpen
prop isfalse
? (that would be my guess without being able to actually run and test anything)– brian-lives-outdoors
Mar 21 at 22:24
It does not, so I tried two things: first, changing my
initialState
object to haveisOpen
set totrue
. second, performing asetProps
in my first test case:wrapper.setProps( isOpen: true )
. When Iconsole.log(wrapper)
, it returns:ReactWrapper
– eagercoder
Mar 22 at 0:16
@brian-lives-outdoors, I think this is a good starting point. Meaning the issue, is likely related to the modal not being open. I may need to use
sinon
to spy on theopenModal
method in my reducer, to trigger the opening of the modal, but that seems like overlike. Thoughts?– eagercoder
Mar 22 at 0:18
@brian-lives-outdoors, setting
isOpen
to false, didn't fix it. Any other ideas?– eagercoder
Mar 25 at 19:31