Library with name storybook lets you handy organize pretty functional showroom for all implemented components in your system.
Apart of ability render component, you can interact with added components: different events, variations, custom params... and manipulate them right through interface!
importReactfrom'react';import{ configure, addDecorator }from'@storybook/react';import{TestProvider}from'../src/utils/tests';import{ store }from'../src/redux/store';const req = require.context('../src',true,/\.stories\.tsx$/);functionloadStories(){ req.keys().forEach(req);}// Test provider contains all necessary react contexts for proper application work, such as redux context, @mui/theme provider, and so onaddDecorator((S)=>(<TestProvider store={store}><S/></TestProvider>));configure(loadStories, module);
Create file .storybook/main.js with content:
const path =require('path');module.exports={addons:['@storybook/preset-create-react-app'],core:{builder:'webpack5',},// feel free to modify webpack config here as wellwebpackFinal:async(config)=>{ config.module.rules.push({test:/\.mjs$/,include:/node_modules/,type:'javascript/auto',});// my custom alias for pretty-path module resolution. ~ sign points to root of src folder config.resolve.alias['~']= path.resolve(__dirname,'../src');return config;},};