Robert Knight, Software Engineer at Mendeley
Rob will explore how to take advantage of React's use of JavaScript/JSX and the virtual UI to catch regressions earlier and make writing and debugging tests for React components easier and faster.
19. Caveats
undefined is probably not a function
Automatic mocking
Does not currently run in the browser
Differences between jsdom and (insert browser
here)'s DOM
Browser dev tools
19 / 25
21. Mocking require() with rewire
import rewire from 'rewire';
var TweetList = rewire('../src/TweetList');
class StubTweetItem extends React.Component {
render() {
return <div>stub tweet</div>;
}
}
TweetList.__set__('TweetItem', StubTweetItem);
Can be used in Node and the browser via rewire
webpack
21 / 25