ShakaCode | ShakaCode Blog | Rails On Maui Blog | Rails | ReactJs | JavaScript | Webpack | Productivity |

Jest Test for react-router LINK


#1

New to reactJS and writing a test case in Jest to check the link in the component. I am using react-router and for the link using Link, I’m using react-router 2.0. I saw some posts that suggest you need to stub the react-router one way or the other but those are all related to the version 1.0. Do I still need to do something similar? I am able to get the node by selecting with class but I cannot get the value of href. Please advise.
let link = TestUtils.findRenderedDOMComponentWithClass(widgetComponent, 'link'); let linkNode = ReactDOM.findDOMNode(link); let renderedLink = linkNode.attributes['href'].value; expect(renderedLink).toContain('test-link');


#2

@munir Did you ever solve this one?