Hacker News new | ask | show | jobs
by timfsu 1740 days ago
We've been using Storybook for isolated development of state-heavy components and it's been a nice productivity booster, compared to testing inside the actual app.

As a bonus, the stories that get created live in your codebase and can be integrated into several different types of testing - jest test suites, visual regression testing, and puppeteer / Selenium.

There's certainly an overhead for mocking data properly, but I tend to see that as part of the general challenge of testing frontend / JS code.

1 comments

Yeah, I like having stories for the different states setup on those types of components too. Our actual app takes seconds to refresh in a development mode and then getting the components back into those states would take extra time, or require extra tooling anyway. Even with HMR some changes will require reloads or component state resets.

For complex data from the API I have actually added tooling very similar to VCR that allows me to record API req/responses from the backend into "cassette" JSON files that can be "loaded" on a per-story basis. Don't use it for everything, but it has worked out very well where it has been used.

What's the name of the "VCR" tool?
Custom code I wrote built on top of fetch-mock.
Is it public?