Testing mandatory PropTypes passed to Redux HOC's












5















I would like to write a test which ensures that a react component passes a prop which has propType.isRequired to a child component.



I would like this test to fail if the prop is not provided and pass if it is. I'm using jest-prop-type-error to throw errors in my tests.



Given the following two components:



Parent.js



const Parent = ({ renderReduxChild , childTitle }) => 
{ return renderReduxChild ? <ReduxChild title={childTitle} /> : <NonReduxChild />}


ReduxChild.js



const ReduxChild = ({ title }) => <div>{title}</div>

ReduxChild.propTypes = { title: PropTypes.string.isRequired }

export default connect(mapStateToProps, mapStateToProps)(ReduxChild)


I would like ensure my Parent component passes the childTitle prop without needing to write an explicit test which says:



Parent.test.js



it('should send the required "title" prop to ReduxChild', () => {
const wrapper = shallow(<Parent renderReduxChild={true} childTitle={'expectedTitle'} />)
expect(wrapper.props().title).toBeDefined()
})


Please note the following:




  • If child was not a connected component, I could not pass childTitle to Parent and the test would fail. Since it is a connected component, if I don't pass childTitle the test passes (even though it's required in ReduxChild)

  • I'm aware that this is quite close to testing the functionality of PropTypes, but it's subtly different in that I want to check that Parent is using Child correctly, not that ReduxChild throws a PropTypes error when the prop isn't passed. I want the test to fail at build time when a dev removes the required prop, not at runtime when I exercise the code.


EDIT:



To further illustrate the issue, if I have a second child component NonReduxChild and give it a propType which isRequired and have a test for Parent which renders the NonReduxChild without providing the prop I get an error thrown at build / test time. Wheres with the ReduxChild I do not.



NonReduxChild.js



const NonReduxChild = ({ text }) = <div>{text}</div>
NonReduxChild.propTypes = { text: PropTypes.string.isRequired }


Test output



FAIL  test/components/Parent.test.js (8.782s)

● <Parent /> › when rendering the component › if renderReduxChild is false it should render <NonReduxChild />

Warning: Failed prop type: The prop `title` is marked as required in `NonReduxChild`, but its value is `undefined`.
in NonReduxChild

28 | render() {
29 | const { renderReduxChild, childTitle } = this.state
> 30 | return renderReduxChild ? <ReduxChild title={childTitle } /> : <NonReduxChild />
| ^
31 | }
32 | }
33 |


As you can see from the test output, when I don't provide a required prop to NonReduxChild I get a test failure which nicely captures the usage of NonReduxChild from other components which might not provide required PropTypes I don't get this same failure from ReduxChild I have to write a specific test (which I don't want to do across a codebase with hundreds of components).










share|improve this question

























  • It's unclear why ensure my Parent component passes the childTitle prop without needing to write an explicit test which says is a requirement. This is a correct way to unit-test a component.

    – estus
    Nov 13 '18 at 16:19











  • Well, this is because I don't want to test every single prop on every single Parent component which uses a Child component throughout a large app. As I mentioned in the notes, if Child was not a connect()ed component, and my app code didn't pass the isRequired prop then any Parent test would fail without me needing to write an explicit test.

    – dougajmcdonald
    Nov 13 '18 at 16:26






  • 1





    You're definitely right that this is probably more an integration test. I will update tags. In terms of unit testing, the Child component does have tests for each required prop so that side of things is covered. A required propType for Child which isn't provided will blow up in the browser at runtime, rather than at build time which is what I'm after, if you'd like I can update the question to demonstrate how a non redux connected component behaves with the same setup if that makes things clearer?

    – dougajmcdonald
    Nov 14 '18 at 8:50






  • 1





    I can update the question to demonstrate how a non redux connected component behaves with the same setup if that makes things clearer? Yes, this would be fine. I'll try to give an answer then.

    – estus
    Nov 14 '18 at 9:03






  • 1





    @estus - I've updated to show how a NonReduxChild behaves

    – dougajmcdonald
    Nov 16 '18 at 9:14
















5















I would like to write a test which ensures that a react component passes a prop which has propType.isRequired to a child component.



I would like this test to fail if the prop is not provided and pass if it is. I'm using jest-prop-type-error to throw errors in my tests.



Given the following two components:



Parent.js



const Parent = ({ renderReduxChild , childTitle }) => 
{ return renderReduxChild ? <ReduxChild title={childTitle} /> : <NonReduxChild />}


ReduxChild.js



const ReduxChild = ({ title }) => <div>{title}</div>

ReduxChild.propTypes = { title: PropTypes.string.isRequired }

export default connect(mapStateToProps, mapStateToProps)(ReduxChild)


I would like ensure my Parent component passes the childTitle prop without needing to write an explicit test which says:



Parent.test.js



it('should send the required "title" prop to ReduxChild', () => {
const wrapper = shallow(<Parent renderReduxChild={true} childTitle={'expectedTitle'} />)
expect(wrapper.props().title).toBeDefined()
})


Please note the following:




  • If child was not a connected component, I could not pass childTitle to Parent and the test would fail. Since it is a connected component, if I don't pass childTitle the test passes (even though it's required in ReduxChild)

  • I'm aware that this is quite close to testing the functionality of PropTypes, but it's subtly different in that I want to check that Parent is using Child correctly, not that ReduxChild throws a PropTypes error when the prop isn't passed. I want the test to fail at build time when a dev removes the required prop, not at runtime when I exercise the code.


EDIT:



To further illustrate the issue, if I have a second child component NonReduxChild and give it a propType which isRequired and have a test for Parent which renders the NonReduxChild without providing the prop I get an error thrown at build / test time. Wheres with the ReduxChild I do not.



NonReduxChild.js



const NonReduxChild = ({ text }) = <div>{text}</div>
NonReduxChild.propTypes = { text: PropTypes.string.isRequired }


Test output



FAIL  test/components/Parent.test.js (8.782s)

● <Parent /> › when rendering the component › if renderReduxChild is false it should render <NonReduxChild />

Warning: Failed prop type: The prop `title` is marked as required in `NonReduxChild`, but its value is `undefined`.
in NonReduxChild

28 | render() {
29 | const { renderReduxChild, childTitle } = this.state
> 30 | return renderReduxChild ? <ReduxChild title={childTitle } /> : <NonReduxChild />
| ^
31 | }
32 | }
33 |


As you can see from the test output, when I don't provide a required prop to NonReduxChild I get a test failure which nicely captures the usage of NonReduxChild from other components which might not provide required PropTypes I don't get this same failure from ReduxChild I have to write a specific test (which I don't want to do across a codebase with hundreds of components).










share|improve this question

























  • It's unclear why ensure my Parent component passes the childTitle prop without needing to write an explicit test which says is a requirement. This is a correct way to unit-test a component.

    – estus
    Nov 13 '18 at 16:19











  • Well, this is because I don't want to test every single prop on every single Parent component which uses a Child component throughout a large app. As I mentioned in the notes, if Child was not a connect()ed component, and my app code didn't pass the isRequired prop then any Parent test would fail without me needing to write an explicit test.

    – dougajmcdonald
    Nov 13 '18 at 16:26






  • 1





    You're definitely right that this is probably more an integration test. I will update tags. In terms of unit testing, the Child component does have tests for each required prop so that side of things is covered. A required propType for Child which isn't provided will blow up in the browser at runtime, rather than at build time which is what I'm after, if you'd like I can update the question to demonstrate how a non redux connected component behaves with the same setup if that makes things clearer?

    – dougajmcdonald
    Nov 14 '18 at 8:50






  • 1





    I can update the question to demonstrate how a non redux connected component behaves with the same setup if that makes things clearer? Yes, this would be fine. I'll try to give an answer then.

    – estus
    Nov 14 '18 at 9:03






  • 1





    @estus - I've updated to show how a NonReduxChild behaves

    – dougajmcdonald
    Nov 16 '18 at 9:14














5












5








5








I would like to write a test which ensures that a react component passes a prop which has propType.isRequired to a child component.



I would like this test to fail if the prop is not provided and pass if it is. I'm using jest-prop-type-error to throw errors in my tests.



Given the following two components:



Parent.js



const Parent = ({ renderReduxChild , childTitle }) => 
{ return renderReduxChild ? <ReduxChild title={childTitle} /> : <NonReduxChild />}


ReduxChild.js



const ReduxChild = ({ title }) => <div>{title}</div>

ReduxChild.propTypes = { title: PropTypes.string.isRequired }

export default connect(mapStateToProps, mapStateToProps)(ReduxChild)


I would like ensure my Parent component passes the childTitle prop without needing to write an explicit test which says:



Parent.test.js



it('should send the required "title" prop to ReduxChild', () => {
const wrapper = shallow(<Parent renderReduxChild={true} childTitle={'expectedTitle'} />)
expect(wrapper.props().title).toBeDefined()
})


Please note the following:




  • If child was not a connected component, I could not pass childTitle to Parent and the test would fail. Since it is a connected component, if I don't pass childTitle the test passes (even though it's required in ReduxChild)

  • I'm aware that this is quite close to testing the functionality of PropTypes, but it's subtly different in that I want to check that Parent is using Child correctly, not that ReduxChild throws a PropTypes error when the prop isn't passed. I want the test to fail at build time when a dev removes the required prop, not at runtime when I exercise the code.


EDIT:



To further illustrate the issue, if I have a second child component NonReduxChild and give it a propType which isRequired and have a test for Parent which renders the NonReduxChild without providing the prop I get an error thrown at build / test time. Wheres with the ReduxChild I do not.



NonReduxChild.js



const NonReduxChild = ({ text }) = <div>{text}</div>
NonReduxChild.propTypes = { text: PropTypes.string.isRequired }


Test output



FAIL  test/components/Parent.test.js (8.782s)

● <Parent /> › when rendering the component › if renderReduxChild is false it should render <NonReduxChild />

Warning: Failed prop type: The prop `title` is marked as required in `NonReduxChild`, but its value is `undefined`.
in NonReduxChild

28 | render() {
29 | const { renderReduxChild, childTitle } = this.state
> 30 | return renderReduxChild ? <ReduxChild title={childTitle } /> : <NonReduxChild />
| ^
31 | }
32 | }
33 |


As you can see from the test output, when I don't provide a required prop to NonReduxChild I get a test failure which nicely captures the usage of NonReduxChild from other components which might not provide required PropTypes I don't get this same failure from ReduxChild I have to write a specific test (which I don't want to do across a codebase with hundreds of components).










share|improve this question
















I would like to write a test which ensures that a react component passes a prop which has propType.isRequired to a child component.



I would like this test to fail if the prop is not provided and pass if it is. I'm using jest-prop-type-error to throw errors in my tests.



Given the following two components:



Parent.js



const Parent = ({ renderReduxChild , childTitle }) => 
{ return renderReduxChild ? <ReduxChild title={childTitle} /> : <NonReduxChild />}


ReduxChild.js



const ReduxChild = ({ title }) => <div>{title}</div>

ReduxChild.propTypes = { title: PropTypes.string.isRequired }

export default connect(mapStateToProps, mapStateToProps)(ReduxChild)


I would like ensure my Parent component passes the childTitle prop without needing to write an explicit test which says:



Parent.test.js



it('should send the required "title" prop to ReduxChild', () => {
const wrapper = shallow(<Parent renderReduxChild={true} childTitle={'expectedTitle'} />)
expect(wrapper.props().title).toBeDefined()
})


Please note the following:




  • If child was not a connected component, I could not pass childTitle to Parent and the test would fail. Since it is a connected component, if I don't pass childTitle the test passes (even though it's required in ReduxChild)

  • I'm aware that this is quite close to testing the functionality of PropTypes, but it's subtly different in that I want to check that Parent is using Child correctly, not that ReduxChild throws a PropTypes error when the prop isn't passed. I want the test to fail at build time when a dev removes the required prop, not at runtime when I exercise the code.


EDIT:



To further illustrate the issue, if I have a second child component NonReduxChild and give it a propType which isRequired and have a test for Parent which renders the NonReduxChild without providing the prop I get an error thrown at build / test time. Wheres with the ReduxChild I do not.



NonReduxChild.js



const NonReduxChild = ({ text }) = <div>{text}</div>
NonReduxChild.propTypes = { text: PropTypes.string.isRequired }


Test output



FAIL  test/components/Parent.test.js (8.782s)

● <Parent /> › when rendering the component › if renderReduxChild is false it should render <NonReduxChild />

Warning: Failed prop type: The prop `title` is marked as required in `NonReduxChild`, but its value is `undefined`.
in NonReduxChild

28 | render() {
29 | const { renderReduxChild, childTitle } = this.state
> 30 | return renderReduxChild ? <ReduxChild title={childTitle } /> : <NonReduxChild />
| ^
31 | }
32 | }
33 |


As you can see from the test output, when I don't provide a required prop to NonReduxChild I get a test failure which nicely captures the usage of NonReduxChild from other components which might not provide required PropTypes I don't get this same failure from ReduxChild I have to write a specific test (which I don't want to do across a codebase with hundreds of components).







reactjs redux react-redux integration-testing jestjs






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 16 '18 at 9:13







dougajmcdonald

















asked Nov 13 '18 at 15:30









dougajmcdonalddougajmcdonald

13k73975




13k73975













  • It's unclear why ensure my Parent component passes the childTitle prop without needing to write an explicit test which says is a requirement. This is a correct way to unit-test a component.

    – estus
    Nov 13 '18 at 16:19











  • Well, this is because I don't want to test every single prop on every single Parent component which uses a Child component throughout a large app. As I mentioned in the notes, if Child was not a connect()ed component, and my app code didn't pass the isRequired prop then any Parent test would fail without me needing to write an explicit test.

    – dougajmcdonald
    Nov 13 '18 at 16:26






  • 1





    You're definitely right that this is probably more an integration test. I will update tags. In terms of unit testing, the Child component does have tests for each required prop so that side of things is covered. A required propType for Child which isn't provided will blow up in the browser at runtime, rather than at build time which is what I'm after, if you'd like I can update the question to demonstrate how a non redux connected component behaves with the same setup if that makes things clearer?

    – dougajmcdonald
    Nov 14 '18 at 8:50






  • 1





    I can update the question to demonstrate how a non redux connected component behaves with the same setup if that makes things clearer? Yes, this would be fine. I'll try to give an answer then.

    – estus
    Nov 14 '18 at 9:03






  • 1





    @estus - I've updated to show how a NonReduxChild behaves

    – dougajmcdonald
    Nov 16 '18 at 9:14



















  • It's unclear why ensure my Parent component passes the childTitle prop without needing to write an explicit test which says is a requirement. This is a correct way to unit-test a component.

    – estus
    Nov 13 '18 at 16:19











  • Well, this is because I don't want to test every single prop on every single Parent component which uses a Child component throughout a large app. As I mentioned in the notes, if Child was not a connect()ed component, and my app code didn't pass the isRequired prop then any Parent test would fail without me needing to write an explicit test.

    – dougajmcdonald
    Nov 13 '18 at 16:26






  • 1





    You're definitely right that this is probably more an integration test. I will update tags. In terms of unit testing, the Child component does have tests for each required prop so that side of things is covered. A required propType for Child which isn't provided will blow up in the browser at runtime, rather than at build time which is what I'm after, if you'd like I can update the question to demonstrate how a non redux connected component behaves with the same setup if that makes things clearer?

    – dougajmcdonald
    Nov 14 '18 at 8:50






  • 1





    I can update the question to demonstrate how a non redux connected component behaves with the same setup if that makes things clearer? Yes, this would be fine. I'll try to give an answer then.

    – estus
    Nov 14 '18 at 9:03






  • 1





    @estus - I've updated to show how a NonReduxChild behaves

    – dougajmcdonald
    Nov 16 '18 at 9:14

















It's unclear why ensure my Parent component passes the childTitle prop without needing to write an explicit test which says is a requirement. This is a correct way to unit-test a component.

– estus
Nov 13 '18 at 16:19





It's unclear why ensure my Parent component passes the childTitle prop without needing to write an explicit test which says is a requirement. This is a correct way to unit-test a component.

– estus
Nov 13 '18 at 16:19













Well, this is because I don't want to test every single prop on every single Parent component which uses a Child component throughout a large app. As I mentioned in the notes, if Child was not a connect()ed component, and my app code didn't pass the isRequired prop then any Parent test would fail without me needing to write an explicit test.

– dougajmcdonald
Nov 13 '18 at 16:26





Well, this is because I don't want to test every single prop on every single Parent component which uses a Child component throughout a large app. As I mentioned in the notes, if Child was not a connect()ed component, and my app code didn't pass the isRequired prop then any Parent test would fail without me needing to write an explicit test.

– dougajmcdonald
Nov 13 '18 at 16:26




1




1





You're definitely right that this is probably more an integration test. I will update tags. In terms of unit testing, the Child component does have tests for each required prop so that side of things is covered. A required propType for Child which isn't provided will blow up in the browser at runtime, rather than at build time which is what I'm after, if you'd like I can update the question to demonstrate how a non redux connected component behaves with the same setup if that makes things clearer?

– dougajmcdonald
Nov 14 '18 at 8:50





You're definitely right that this is probably more an integration test. I will update tags. In terms of unit testing, the Child component does have tests for each required prop so that side of things is covered. A required propType for Child which isn't provided will blow up in the browser at runtime, rather than at build time which is what I'm after, if you'd like I can update the question to demonstrate how a non redux connected component behaves with the same setup if that makes things clearer?

– dougajmcdonald
Nov 14 '18 at 8:50




1




1





I can update the question to demonstrate how a non redux connected component behaves with the same setup if that makes things clearer? Yes, this would be fine. I'll try to give an answer then.

– estus
Nov 14 '18 at 9:03





I can update the question to demonstrate how a non redux connected component behaves with the same setup if that makes things clearer? Yes, this would be fine. I'll try to give an answer then.

– estus
Nov 14 '18 at 9:03




1




1





@estus - I've updated to show how a NonReduxChild behaves

– dougajmcdonald
Nov 16 '18 at 9:14





@estus - I've updated to show how a NonReduxChild behaves

– dougajmcdonald
Nov 16 '18 at 9:14












2 Answers
2






active

oldest

votes


















0














I believe the issue you are running into is that PropTypes just logs warnings, which don't actually cause tests to fail.



If the prop is critically important to the operation of the component and you are set on not writing tests to assert that props are present, you could always have the component throw an error if that prop isn't present. That will cause the tests to fail.






share|improve this answer
























  • Thanks for the reply, but I'm using jest-prop-type-error to throw errors in tests, this also doesn't address the parent > child issue, nor the redux vs non redux child differences

    – dougajmcdonald
    Nov 18 '18 at 0:27



















0














I think you can define title as prop and u could call it, instead of "childTitle".
Try this.. it may work



it('should send the required "title" prop to ReduxChild', () => {
`var wrapper = shallow(<Parent renderReduxChild={true} title={"expectedTitle"} />);`
expect(wrapper.props().title).toBeDefined()
`console.log("",childTitle);`
})





share|improve this answer


























  • Thanks for the contribution but I'm not sure that your answer addresses the issue

    – dougajmcdonald
    Nov 24 '18 at 18:03











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
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53284338%2ftesting-mandatory-proptypes-passed-to-redux-hocs%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














I believe the issue you are running into is that PropTypes just logs warnings, which don't actually cause tests to fail.



If the prop is critically important to the operation of the component and you are set on not writing tests to assert that props are present, you could always have the component throw an error if that prop isn't present. That will cause the tests to fail.






share|improve this answer
























  • Thanks for the reply, but I'm using jest-prop-type-error to throw errors in tests, this also doesn't address the parent > child issue, nor the redux vs non redux child differences

    – dougajmcdonald
    Nov 18 '18 at 0:27
















0














I believe the issue you are running into is that PropTypes just logs warnings, which don't actually cause tests to fail.



If the prop is critically important to the operation of the component and you are set on not writing tests to assert that props are present, you could always have the component throw an error if that prop isn't present. That will cause the tests to fail.






share|improve this answer
























  • Thanks for the reply, but I'm using jest-prop-type-error to throw errors in tests, this also doesn't address the parent > child issue, nor the redux vs non redux child differences

    – dougajmcdonald
    Nov 18 '18 at 0:27














0












0








0







I believe the issue you are running into is that PropTypes just logs warnings, which don't actually cause tests to fail.



If the prop is critically important to the operation of the component and you are set on not writing tests to assert that props are present, you could always have the component throw an error if that prop isn't present. That will cause the tests to fail.






share|improve this answer













I believe the issue you are running into is that PropTypes just logs warnings, which don't actually cause tests to fail.



If the prop is critically important to the operation of the component and you are set on not writing tests to assert that props are present, you could always have the component throw an error if that prop isn't present. That will cause the tests to fail.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 16 '18 at 16:13









Steve VaughanSteve Vaughan

1,104411




1,104411













  • Thanks for the reply, but I'm using jest-prop-type-error to throw errors in tests, this also doesn't address the parent > child issue, nor the redux vs non redux child differences

    – dougajmcdonald
    Nov 18 '18 at 0:27



















  • Thanks for the reply, but I'm using jest-prop-type-error to throw errors in tests, this also doesn't address the parent > child issue, nor the redux vs non redux child differences

    – dougajmcdonald
    Nov 18 '18 at 0:27

















Thanks for the reply, but I'm using jest-prop-type-error to throw errors in tests, this also doesn't address the parent > child issue, nor the redux vs non redux child differences

– dougajmcdonald
Nov 18 '18 at 0:27





Thanks for the reply, but I'm using jest-prop-type-error to throw errors in tests, this also doesn't address the parent > child issue, nor the redux vs non redux child differences

– dougajmcdonald
Nov 18 '18 at 0:27













0














I think you can define title as prop and u could call it, instead of "childTitle".
Try this.. it may work



it('should send the required "title" prop to ReduxChild', () => {
`var wrapper = shallow(<Parent renderReduxChild={true} title={"expectedTitle"} />);`
expect(wrapper.props().title).toBeDefined()
`console.log("",childTitle);`
})





share|improve this answer


























  • Thanks for the contribution but I'm not sure that your answer addresses the issue

    – dougajmcdonald
    Nov 24 '18 at 18:03
















0














I think you can define title as prop and u could call it, instead of "childTitle".
Try this.. it may work



it('should send the required "title" prop to ReduxChild', () => {
`var wrapper = shallow(<Parent renderReduxChild={true} title={"expectedTitle"} />);`
expect(wrapper.props().title).toBeDefined()
`console.log("",childTitle);`
})





share|improve this answer


























  • Thanks for the contribution but I'm not sure that your answer addresses the issue

    – dougajmcdonald
    Nov 24 '18 at 18:03














0












0








0







I think you can define title as prop and u could call it, instead of "childTitle".
Try this.. it may work



it('should send the required "title" prop to ReduxChild', () => {
`var wrapper = shallow(<Parent renderReduxChild={true} title={"expectedTitle"} />);`
expect(wrapper.props().title).toBeDefined()
`console.log("",childTitle);`
})





share|improve this answer















I think you can define title as prop and u could call it, instead of "childTitle".
Try this.. it may work



it('should send the required "title" prop to ReduxChild', () => {
`var wrapper = shallow(<Parent renderReduxChild={true} title={"expectedTitle"} />);`
expect(wrapper.props().title).toBeDefined()
`console.log("",childTitle);`
})






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 23 '18 at 8:58









Urosh T.

66711216




66711216










answered Nov 23 '18 at 7:52









Geeky_Mr.VGeeky_Mr.V

193




193













  • Thanks for the contribution but I'm not sure that your answer addresses the issue

    – dougajmcdonald
    Nov 24 '18 at 18:03



















  • Thanks for the contribution but I'm not sure that your answer addresses the issue

    – dougajmcdonald
    Nov 24 '18 at 18:03

















Thanks for the contribution but I'm not sure that your answer addresses the issue

– dougajmcdonald
Nov 24 '18 at 18:03





Thanks for the contribution but I'm not sure that your answer addresses the issue

– dougajmcdonald
Nov 24 '18 at 18:03


















draft saved

draft discarded




















































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.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53284338%2ftesting-mandatory-proptypes-passed-to-redux-hocs%23new-answer', 'question_page');
}
);

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







Popular posts from this blog

Full-time equivalent

Bicuculline

さくらももこ