Skip to content

Commit

Permalink
Add storybook for UI testing
Browse files Browse the repository at this point in the history
  • Loading branch information
devjiwonchoi committed Dec 17, 2024
1 parent b291d84 commit 21b5f18
Show file tree
Hide file tree
Showing 5 changed files with 1,500 additions and 20 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,6 @@ test-timings.json
*.tsbuildinfo
.swc/
.turbo

# Storybook
*storybook.log
29 changes: 29 additions & 0 deletions packages/next/.storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import type { StorybookConfig } from '@storybook/react-webpack5'

import { join, dirname } from 'path'

/**
* This function is used to resolve the absolute path of a package.
* It is needed in projects that use Yarn PnP or are set up within a monorepo.
*/
function getAbsolutePath(value: string): any {
return dirname(require.resolve(join(value, 'package.json')))
}
const config: StorybookConfig = {
stories: [
'../stories/**/*.mdx',
'../stories/**/*.stories.@(js|jsx|mjs|ts|tsx)',
],
addons: [
getAbsolutePath('@storybook/addon-webpack5-compiler-swc'),
getAbsolutePath('@storybook/addon-onboarding'),
getAbsolutePath('@storybook/addon-essentials'),
getAbsolutePath('@chromatic-com/storybook'),
getAbsolutePath('@storybook/addon-interactions'),
],
framework: {
name: getAbsolutePath('@storybook/react-webpack5'),
options: {},
},
}
export default config
14 changes: 14 additions & 0 deletions packages/next/.storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import type { Preview } from '@storybook/react'

const preview: Preview = {
parameters: {
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/i,
},
},
},
}

export default preview
14 changes: 13 additions & 1 deletion packages/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@
"prepublishOnly": "cd ../../ && turbo run build",
"types": "tsc --declaration --emitDeclarationOnly --stripInternal --declarationDir dist",
"typescript": "tsec --noEmit",
"ncc-compiled": "taskr ncc"
"ncc-compiled": "taskr ncc",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build"
},
"taskr": {
"requires": [
Expand Down Expand Up @@ -153,6 +155,7 @@
"@babel/traverse": "7.22.5",
"@babel/types": "7.22.5",
"@capsizecss/metrics": "3.4.0",
"@chromatic-com/storybook": "^3.2.2",
"@edge-runtime/cookies": "6.0.0",
"@edge-runtime/ponyfill": "4.0.0",
"@edge-runtime/primitives": "6.0.0",
Expand All @@ -168,6 +171,14 @@
"@next/swc": "15.1.1-canary.7",
"@opentelemetry/api": "1.6.0",
"@playwright/test": "1.41.2",
"@storybook/addon-essentials": "^8.4.7",
"@storybook/addon-interactions": "^8.4.7",
"@storybook/addon-onboarding": "^8.4.7",
"@storybook/addon-webpack5-compiler-swc": "^1.0.5",
"@storybook/blocks": "^8.4.7",
"@storybook/react": "^8.4.7",
"@storybook/react-webpack5": "^8.4.7",
"@storybook/test": "^8.4.7",
"@swc/core": "1.9.3",
"@swc/types": "0.1.7",
"@taskr/clear": "1.1.0",
Expand Down Expand Up @@ -306,6 +317,7 @@
"source-map-loader": "5.0.0",
"source-map08": "npm:[email protected]",
"stacktrace-parser": "0.1.10",
"storybook": "^8.4.7",
"stream-browserify": "3.0.0",
"stream-http": "3.1.1",
"strict-event-emitter": "0.5.0",
Expand Down
Loading

0 comments on commit 21b5f18

Please sign in to comment.