YukoKano / storybook-tutorial

https://storybook.js.org/tutorials/intro-to-storybook/react/ja/get-started/
MIT License
0 stars 0 forks source link

Intro to Storybook 実践memo #1

Open YukoKano opened 2 months ago

YukoKano commented 2 months ago

サンプル通りにやったのにyarn test --watchAllでtestないよって言われた

YukoKano commented 2 months ago
yarn add jest

してpackage.jsonを追加して直った

"scripts": {
    "test": "jest --watchAll"
  }
YukoKano commented 2 months ago

このコミュニティの翻訳は、最新の Storybook バージョンに対応していません。英語ガイドの最新の変更を適用して、この日本語ガイドの更新にご協力ください。 Pull requests を大歓迎します。

バージョンが古かったからおかしかったのかもしれん 今8だもんね

YukoKano commented 2 months ago
ou@kurogoma taskbox % yarn storybook
yarn run v1.22.19
warning ../../../../package.json: No license field
$ storybook dev -p 6006
@storybook/cli v8.1.4

SB_CORE-COMMON_0002 (InvalidFrameworkNameError): Invalid value of '@storybook/react' in the 'framework' field of Storybook config.

Please run 'npx storybook automigrate' to automatically fix your config.

More info: https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#new-framework-api

    at validateFrameworkName (./node_modules/@storybook/core-common/dist/index.js:50:2172)
    at buildDevStandalone (./node_modules/@storybook/core-server/dist/index.js:65:1673)
    at async withTelemetry (./node_modules/@storybook/core-server/dist/index.js:28:3599)
    at async dev (./node_modules/@storybook/cli/dist/generate.js:705:563)
    at async Command.<anonymous> (./node_modules/@storybook/cli/dist/generate.js:707:250)

WARN Broken build, fix the error above.
WARN You may need to refresh the browser.

WARN Could not resolve addon "@storybook/preset-create-react-app", skipping. Is it installed?
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

npx storybook automigrate

したらよしなに調整してくれたっぽい、?

YukoKano commented 2 months ago

これダメだ、作り直します。

YukoKano commented 1 month ago

作り直した、次は「Build out the states」から https://storybook.js.org/tutorials/intro-to-storybook/react/en/simple-component/

YukoKano commented 1 month ago

きちんと型定義しないとこういうエラーが出るっぽい

image
YukoKano commented 1 month ago

Addon でこういうパネルも検証することができるのか

image

YukoKano commented 1 month ago

次はここから https://storybook.js.org/tutorials/intro-to-storybook/react/en/composite-component/

YukoKano commented 1 month ago

image

YukoKano commented 1 month ago

Data requirements and props から

YukoKano commented 1 month ago

PropTypes、非推奨になってるやんけ

https://ja.react.dev/blog/2024/04/25/react-19-upgrade-guide#removed-proptypes-and-defaultprops

早めにTypeScriptやっといたほうがいいんだろうか

YukoKano commented 1 month ago

TODO:const { hoge } import { hoge } 、とconst hoge import hoge、で何が違うのか記事書く

kano-yuko commented 1 month ago

山田さん)argsでどういう挙動になるのかが分かれば良さそう

YukoKano commented 1 month ago

ページをStoryして、エラーが出ると書いてあったけど特段エラーは出てないんだよな、 image

Mocking API Servicesから続きやる

↑エラーページがちゃんとエラーページを吐かないのがエラーだったっぽい

YukoKano commented 1 month ago
yarn test-storybook --watch

をするためにはStorybook立ち上げておかないといけないっぽい

Storybook's test runner requires either a locally running Storybook instance or a published Storybook to run all the existing tests.


動いたが、テスト環境ないよって言われて、これを↓たたいた

yarn playwright install  

自動テストのためのツールっぽい

yarn playwright installコマンドは、Playwrightのブラウザバイナリをインストールするためのコマンドです。Playwrightは、Node.js用のエンドツーエンドテストツールで、Chromium、Firefox、WebKitなどの異なるブラウザで自動テストを実行することができます。

yarn playwright installコマンドは、Playwrightが初めてインストールされたときに一度だけ実行すれば十分です。その後のテスト実行時には、インストールされたブラウザバイナリを利用するだけで済みます。 例えば、@storybook/test-runnerはPlaywrightを使用してStorybookのコンポーネントをテストするため、yarn playwright installが必要になることがあります。


通った↓

image
YukoKano commented 1 month ago
import {
  fireEvent,
  waitFor,
  within,
  waitForElementToBeRemoved,
} from "@storybook/test";

この辺からの記述がわからん

YukoKano commented 1 month ago

変数を設定した

image

YukoKano commented 1 month ago

ファイルの依存関係がおかしくなっていてずっとエラーが出ているので修正している

YukoKano commented 1 month ago

通った〜〜〜〜〜〜〜〜〜〜!ChatGPTありがとう!!!!!

image

YukoKano commented 1 month ago

学び:

YukoKano commented 1 month ago

あんがとね

image

YukoKano commented 1 month ago

Visual Testsからやる

YukoKano commented 1 month ago

終わった〜!

YukoKano commented 1 month ago

1日30分、約11日で完了している =330分 =6時間半