2 ms·
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 dependen
by namuol 10y ago
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.
Sources:
Storybook - https://github.com/kadirahq/react-storybook https://github.com/kadirahq/react-storybook
Jest's "Tree Snapshot" testing - https://facebook.github.io/jest/blog/2016/07/27/jest-14.html https://facebook.github.io/jest/blog/2016/07/27/jest-14.html