Re:The only React.js test you'll ever need
by namuol on Thursday August 04, 2016 @04:43PM
(#12228326)
In a similar vein, I use Storybook to build my presentational components, and run each story in a try/catch to check for "explosions".
If you add some dependency injection to look for `console.warn` or `console.error` calls, you can catch failed PropTypes or similar.
Today you can even combine all of these with Jest's new "Tree Snapshot Testing" to compare the actual output of `render` with an expected/approved output.
Finally, you can use your stories in combination with a service like Browserstack or SauceLabs to run these tests across platforms, and even take screenshots of each story and compare them to test for styling regressions and cross-platform differences.
Re:The only React.js test you'll ever need
by venusiant on Thursday August 04, 2016 @09:25AM
(#12225296)
Hmmm... this is good but presumably react components are actually going to do things. But I suppose you're saying that the code that actually does things should be separated from the react code and should be tested separately from the react components.
If you add some dependency injection to look for `console.warn` or `console.error` calls, you can catch failed PropTypes or similar.
Today you can even combine all of these with Jest's new "Tree Snapshot Testing" to compare the actual output of `render` with an expected/approved output.
Finally, you can use your stories in combination with a service like Browserstack or SauceLabs to run these tests across platforms, and even take screenshots of each story and compare them to test for styling regressions and cross-platform differences.
Sources:
Storybook - https://github.com/kadirahq/react-storybook
Jest's "Tree Snapshot" testing - https://facebook.github.io/jest/blog/2016/07/27/jest-14.html