How We Test Storybook Itself

Rate this content
Bookmark

Storybook is a complex OSS project, integrating with a wide range of stacks, and used in various ways by millions of devs. What's it like maintaining a project like that? How do we ensure it doesn't break?

FAQ

Storybook is a tool used for building and testing UI components in isolation. It allows developers to catalog and visualize different states and variations of components, making it easier to share these components with stakeholders and handle complex scenarios.

TypeScript is favored in the Storybook codebase because it helps to ensure that different packages and code paths interlink correctly, providing a higher level of confidence in the code's functionality and reducing the likelihood of bugs.

Storybook is designed to be compatible with multiple builders like Webpack and Vite, various JavaScript frameworks such as React, Vue, Angular, and Svelte, as well as meta frameworks including Next.js and SvelteKit. It also supports different package managers like npm, yarn, and pnpm.

Storybook uses a combination of unit tests, UI tests (with its own Storybook), and integration tests across various configurations and environments to ensure that additions and changes do not break functionality. It also tests performance and install size for each build.

Maintaining backwards compatibility is a challenge for Storybook due to its evolving codebase and changing functionalities over the years. The team addresses this by providing clear migration guides and auto-migrations where possible.

Storybook manages its configurability by modularizing features into add-ons and using feature flags. It tests configurations by overriding settings in sandbox environments to simulate different user scenarios.

While Storybook is primarily designed as a desktop application, it can still be used as a quick reference tool on mobile devices. Improvements for mobile UI are planned for future updates to enhance usability on mobile platforms.

Storybook typically follows a release cadence of every 4 to 6 weeks for minor updates, with major versions released once or twice a year. Alpha releases and canary builds are also frequently made available to test new features.

Norbert de Langen
Norbert de Langen
30 min
07 Dec, 2023

Comments

Sign in or register to post your comment.

Video Summary and Transcription

This Talk discusses the use of TypeScript and Storybook in software development. It covers the premise of components and the complexity of testing Storybook. The setup process for Next.js and Storybook is explained, along with the testing workflow and CI integration. The Talk also touches on caching, bug reports, and the release process. Documentation management and improving test run time are discussed, as well as testing feature flags and mobile usage.

Available in Español: Cómo probamos Storybook en sí

1. Introduction to TypeScript and Storybook

Short description:

We're going to talk about how you can use TypeScript to write JavaScript with TypeScript. This one is more of a case study. Storybook is a tool that you can use to build better components. Because the core principle of Storybook is that you can work on them in isolation. You can catalog all of those components and all of their states, all of the variances. And you can very importantly test them. Storybook is quite popular, which is very humbling for me. But oftentimes, you kind of learn how code runs and how it works by how it's used.

We're going to talk about how you can use TypeScript to write JavaScript with TypeScript. We'll talk about how you can use TypeScript to write JavaScript with TypeScript. We'll talk about how you can use TypeScript to write JavaScript with TypeScript. We'll talk about how you can use TypeScript to write JavaScript with TypeScript. We'll talk about how you can use TypeScript to write JavaScript with TypeScript.

Not perfect. And this is kind of a talk of a type that I've never given before. So before, I always gave a talk about, oh, you should do this new thing right now. This one is more of a case study. And so there's a lot of interesting bits for me. I hope they're interesting for you as well.

I'm from the Netherlands. And as introduced, I work for a company called Chromatic. But my full-time job is maintaining Storybook. So I have to get this out of the way before I can talk about what makes Storybook internals tick and work.

What is Storybook? Storybook is a tool that you can use to build better components. Because the core principle of Storybook is that you can work on them in isolation. Instead of working on your components top to bottom, you can basically start working on any component first. You can catalog all of those components and all of their states, all of the variances. And you can very importantly test them. That is what this conference is all about, right? And then you definitely want to share those components with your stakeholders. Storybook is quite popular, which is very humbling for me. All of these companies are using Storybook. And the reason is that at some point when you're building applications, you might start with some easy components. And everything feels super easy. But at some point, you reach a level of components that is just complex. I've seen components of like 5,000 lines of code. And everything is contained within the file. Like if you were to understand all of it, you could. But oftentimes, you kind of learn how code runs and how it works by how it's used.

2. The Premise of Components and Storybook

Short description:

The premise of components is that you can use them all over. Storybook brings together different edge cases and allows you to visualize them. These edge cases can be combinatorial, combining various states and languages.

The premise of components is that you can use them all over. So if a component that is complex has all of these different variances and variations across the application, well, you're not going to look all across the application and search for all of those use cases. So that's really what Storybook is about. It's bringing all of those different weird edge cases that you might not even encounter in your app normally and bring them together so that you can visualize them there.

Often overlooked is that these weird edge cases can actually be combinatorial. So a loading state and a non-authenticated state and a different language can all coalesce together.

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

A Guide to React Rendering Behavior
React Advanced Conference 2022React Advanced Conference 2022
25 min
A Guide to React Rendering Behavior
Top Content
React is a library for "rendering" UI from components, but many users find themselves confused about how React rendering actually works. What do terms like "rendering", "reconciliation", "Fibers", and "committing" actually mean? When do renders happen? How does Context affect rendering, and how do libraries like Redux cause updates? In this talk, we'll clear up the confusion and provide a solid foundation for understanding when, why, and how React renders. We'll look at: - What "rendering" actually is - How React queues renders and the standard rendering behavior - How keys and component types are used in rendering - Techniques for optimizing render performance - How context usage affects rendering behavior| - How external libraries tie into React rendering
Speeding Up Your React App With Less JavaScript
React Summit 2023React Summit 2023
32 min
Speeding Up Your React App With Less JavaScript
Top Content
Too much JavaScript is getting you down? New frameworks promising no JavaScript look interesting, but you have an existing React application to maintain. What if Qwik React is your answer for faster applications startup and better user experience? Qwik React allows you to easily turn your React application into a collection of islands, which can be SSRed and delayed hydrated, and in some instances, hydration skipped altogether. And all of this in an incremental way without a rewrite.
Network Requests with Cypress
TestJS Summit 2021TestJS Summit 2021
33 min
Network Requests with Cypress
Top Content
Whether you're testing your UI or API, Cypress gives you all the tools needed to work with and manage network requests. This intermediate-level task demonstrates how to use the cy.request and cy.intercept commands to execute, spy on, and stub network requests while testing your application in the browser. Learn how the commands work as well as use cases for each, including best practices for testing and mocking your network requests.
React Concurrency, Explained
React Summit 2023React Summit 2023
23 min
React Concurrency, Explained
Top Content
React 18! Concurrent features! You might’ve already tried the new APIs like useTransition, or you might’ve just heard of them. But do you know how React 18 achieves the performance wins it brings with itself? In this talk, let’s peek under the hood of React 18’s performance features: - How React 18 lowers the time your page stays frozen (aka TBT) - What exactly happens in the main thread when you run useTransition() - What’s the catch with the improvements (there’s no free cake!), and why Vue.js and Preact straight refused to ship anything similar
Testing Pyramid Makes Little Sense, What We Can Use Instead
TestJS Summit 2021TestJS Summit 2021
38 min
Testing Pyramid Makes Little Sense, What We Can Use Instead
Top Content
Featured Video
Gleb Bahmutov
Roman Sandler
2 authors
The testing pyramid - the canonical shape of tests that defined what types of tests we need to write to make sure the app works - is ... obsolete. In this presentation, Roman Sandler and Gleb Bahmutov argue what the testing shape works better for today's web applications.
The Future of Performance Tooling
JSNation 2022JSNation 2022
21 min
The Future of Performance Tooling
Top Content
Our understanding of performance & user-experience has heavily evolved over the years. Web Developer Tooling needs to similarly evolve to make sure it is user-centric, actionable and contextual where modern experiences are concerned. In this talk, Addy will walk you through Chrome and others have been thinking about this problem and what updates they've been making to performance tools to lower the friction for building great experiences on the web.

Workshops on related topic

React Performance Debugging Masterclass
React Summit 2023React Summit 2023
170 min
React Performance Debugging Masterclass
Top Content
Featured WorkshopFree
Ivan Akulov
Ivan Akulov
Ivan’s first attempts at performance debugging were chaotic. He would see a slow interaction, try a random optimization, see that it didn't help, and keep trying other optimizations until he found the right one (or gave up).
Back then, Ivan didn’t know how to use performance devtools well. He would do a recording in Chrome DevTools or React Profiler, poke around it, try clicking random things, and then close it in frustration a few minutes later. Now, Ivan knows exactly where and what to look for. And in this workshop, Ivan will teach you that too.
Here’s how this is going to work. We’ll take a slow app → debug it (using tools like Chrome DevTools, React Profiler, and why-did-you-render) → pinpoint the bottleneck → and then repeat, several times more. We won’t talk about the solutions (in 90% of the cases, it’s just the ol’ regular useMemo() or memo()). But we’ll talk about everything that comes before – and learn how to analyze any React performance problem, step by step.
(Note: This workshop is best suited for engineers who are already familiar with how useMemo() and memo() work – but want to get better at using the performance tools around React. Also, we’ll be covering interaction performance, not load speed, so you won’t hear a word about Lighthouse 🤐)
Designing Effective Tests With React Testing Library
React Summit 2023React Summit 2023
151 min
Designing Effective Tests With React Testing Library
Top Content
Featured Workshop
Josh Justice
Josh Justice
React Testing Library is a great framework for React component tests because there are a lot of questions it answers for you, so you don’t need to worry about those questions. But that doesn’t mean testing is easy. There are still a lot of questions you have to figure out for yourself: How many component tests should you write vs end-to-end tests or lower-level unit tests? How can you test a certain line of code that is tricky to test? And what in the world are you supposed to do about that persistent act() warning?
In this three-hour workshop we’ll introduce React Testing Library along with a mental model for how to think about designing your component tests. This mental model will help you see how to test each bit of logic, whether or not to mock dependencies, and will help improve the design of your components. You’ll walk away with the tools, techniques, and principles you need to implement low-cost, high-value component tests.
Table of contents- The different kinds of React application tests, and where component tests fit in- A mental model for thinking about the inputs and outputs of the components you test- Options for selecting DOM elements to verify and interact with them- The value of mocks and why they shouldn’t be avoided- The challenges with asynchrony in RTL tests and how to handle them
Prerequisites- Familiarity with building applications with React- Basic experience writing automated tests with Jest or another unit testing framework- You do not need any experience with React Testing Library- Machine setup: Node LTS, Yarn
Building WebApps That Light Up the Internet with QwikCity
JSNation 2023JSNation 2023
170 min
Building WebApps That Light Up the Internet with QwikCity
Featured WorkshopFree
Miško Hevery
Miško Hevery
Building instant-on web applications at scale have been elusive. Real-world sites need tracking, analytics, and complex user interfaces and interactions. We always start with the best intentions but end up with a less-than-ideal site.
QwikCity is a new meta-framework that allows you to build large-scale applications with constant startup-up performance. We will look at how to build a QwikCity application and what makes it unique. The workshop will show you how to set up a QwikCitp project. How routing works with layout. The demo application will fetch data and present it to the user in an editable form. And finally, how one can use authentication. All of the basic parts for any large-scale applications.
Along the way, we will also look at what makes Qwik unique, and how resumability enables constant startup performance no matter the application complexity.
How to Start With Cypress
TestJS Summit 2022TestJS Summit 2022
146 min
How to Start With Cypress
Featured WorkshopFree
Filip Hric
Filip Hric
The web has evolved. Finally, testing has also. Cypress is a modern testing tool that answers the testing needs of modern web applications. It has been gaining a lot of traction in the last couple of years, gaining worldwide popularity. If you have been waiting to learn Cypress, wait no more! Filip Hric will guide you through the first steps on how to start using Cypress and set up a project on your own. The good news is, learning Cypress is incredibly easy. You'll write your first test in no time, and then you'll discover how to write a full end-to-end test for a modern web application. You'll learn the core concepts like retry-ability. Discover how to work and interact with your application and learn how to combine API and UI tests. Throughout this whole workshop, we will write code and do practical exercises. You will leave with a hands-on experience that you can translate to your own project.
Next.js 13: Data Fetching Strategies
React Day Berlin 2022React Day Berlin 2022
53 min
Next.js 13: Data Fetching Strategies
Top Content
WorkshopFree
Alice De Mauro
Alice De Mauro
- Introduction- Prerequisites for the workshop- Fetching strategies: fundamentals- Fetching strategies – hands-on: fetch API, cache (static VS dynamic), revalidate, suspense (parallel data fetching)- Test your build and serve it on Vercel- Future: Server components VS Client components- Workshop easter egg (unrelated to the topic, calling out accessibility)- Wrapping up
Detox 101: How to write stable end-to-end tests for your React Native application
React Summit 2022React Summit 2022
117 min
Detox 101: How to write stable end-to-end tests for your React Native application
Top Content
WorkshopFree
Yevheniia Hlovatska
Yevheniia Hlovatska
Compared to unit testing, end-to-end testing aims to interact with your application just like a real user. And as we all know it can be pretty challenging. Especially when we talk about Mobile applications.
Tests rely on many conditions and are considered to be slow and flaky. On the other hand - end-to-end tests can give the greatest confidence that your app is working. And if done right - can become an amazing tool for boosting developer velocity.
Detox is a gray-box end-to-end testing framework for mobile apps. Developed by Wix to solve the problem of slowness and flakiness and used by React Native itself as its E2E testing tool.
Join me on this workshop to learn how to make your mobile end-to-end tests with Detox rock.
Prerequisites- iOS/Android: MacOS Catalina or newer- Android only: Linux- Install before the workshop