Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
1粒で3度おいしいStorybook
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Yosuke Kurami
April 19, 2018
Programming
6.3k
4
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
1粒で3度おいしいStorybook
Yosuke Kurami
April 19, 2018
More Decks by Yosuke Kurami
See All by Yosuke Kurami
TypeScript LSP の今までとこれから
quramy
1
2.2k
フロントエンドテストの育て方
quramy
12
3.9k
App Router 悲喜交々
quramy
8
760
上手に付き合うコンポーネントテスト
quramy
6
2.4k
Patched fetch did not work
quramy
6
810
GraphQL あるいは React における自律的なデータ取得について
quramy
18
6k
Next.js App Router
quramy
15
4k
Fragment Composition of GraphQL
quramy
17
4.9k
reg-viz VRT tools
quramy
4
1.8k
Other Decks in Programming
See All in Programming
LL言語やWebフレームワークのPostgreSQL対応 〜DBの機能がユーザーに届くまで〜
kentaroutakeda
0
140
DroidKaigi 2026 「個人開発という実験場: Android エンジニアが手にする4つの自由」
slashnephy
0
220
go-spidermonkeyでAIエージェントのCode Modeを実装する
syumai
3
1.5k
AI に Inclusive UI を書かせよう — Design Rules Skill で Compose UI を作り直す
theoriatec2024
1
450
変化を抱擁するドキュメントの作り方 - ビジネスルール駆動開発がもたらす、コードとの新しい関係
ioki
2
110
Swift愛好会と私(ウホーイ) / Swift Fan Club and Uhooi
uhooi
0
140
Building an Out-of-Order CPU
latte72
0
690
KotlinConf Extended South Korea 2026 Keynote
l2hyunwoo
0
130
Go 1.27からのGODEBUG / Go 1.27 リリースパーティ #go127party
mazrean
0
320
The Good Stuff, Not the Slop: Engineering High-Quality Android Apps with Modern AI Tooling
danybony
1
180
AWS Step Functions 大規模並列の壁を越える / jaws-sonic-2026-niigata-step-functions
kasacchiful
PRO
0
370
Oxlintはいいぞ(続)
yug1224
1
550
Featured
See All Featured
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6.1k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
510
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
430
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.8k
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
440
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
270
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.4k
Site-Speed That Sticks
csswizardry
13
1.5k
Git: the NoSQL Database
bkeepers
PRO
432
67k
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
Odyssey Design
rkendrick25
PRO
2
800
Transcript
ҰཻͰ ࡾ͓͍͍͠ Storybook
Today’s theme: Storybook in FOLIO
Storybook in FOLIO '0-*0ϑϩϯτνʔϜͰͷ4UPSZCPPLར༻ྫ ϝϦοτΛ3ͭհ͢ΔΑ ༰ͷେ3FBDUʹґଘ͠ͳ͍Α
ؼͬͨΒ4UPSZCPPL͕͍ͨ͘ͳΔʂͣ
Introduction
Storybook is a development environment for UI components. https://github.com/storybooks/storybook
Storybook basics $PNQPOFOUΧλϩάΛੜ͢Δπʔϧ ݩʑ3FBDU͕λʔήοτ ݱࡏ༷ʑͳ6*GSBNFXPSLTʹରԠ "OHVMBS
7VFKT 3FBDU/BUJWF 1PMZNFS
None
1. Developer experience
Story driven development ίϯϙʔωϯτΛ༻ҙ͢Δ ίϯϙʔωϯτΛࢀরͨ͠TUPSJFTϑΝΠϧΛ࡞Δ QSPQTͷύλʔϯʹԠͯ͡TUPSZΛ૿͍ͯ͘͠
).3 )PU.PEVMF3FQMBDFNFOU ରԠͯ͠ΔͷͰɺ αΫαΫը໘Λ։ൃͰ͖Δ
Demo
Tips: Scaffold your stories TUPSJFTͷܗΛੜ͢ΔTDSJQUΛ࡞͓ͬͯ͘ͱศར ྫ+49$44.PEVMFTTUPSJFT NVTUBDIFNJOJNJTUJORVJSFSΛΈ߹ΘͤΔͱ͓
खܰʹ$-*͕࡞ΕΔ ϝϯόʔͷͨΊʹಋೖোนগ͠Ͱ͓ܰͯ͘͘͠
Why do you need component catalogue? ΞϓϦέʔγϣϯʹϨΞέʔεҟৗܥ͕͖ͭͷ ௨ৗಈ࡞Ͱ౸ୡͰ͖ͳ͍ݟͨ
7JFX͕औΓಘΔঢ়ଶͯ͢ΞΫηεՄೳͰ͋Δ͖ ϨΞέʔεͷݟͨΛTUPSZͱͯ͠༻ҙ͢Δ͜ͱͰɺ ৗʹ֬ೝՄೳͳঢ়ଶʹ͓ͯ͘͠
Stories for abnormal properties ࣮ࡍͷΞϓϦέʔγϣϯͰ࠶ݱ͕໘ͳύλʔϯୡ
2. Accelerate communication
With reviewers ʮ7JFX͕औΓಘΔঢ়ଶʹΞΫηεՄೳʯͰ͋Δҙຯ 6*ίϯϙʔωϯτͷมߋΛ4UPSZCPPLͰ֬ೝՄೳ ։ൃऀಉ࢜ͷϨϏϡʔḿΔ
With reviewers ֬ೝ͖͢TUPSZ͕Ұྎવ
With designers 4UPSZCPPLΛνʔϜͰڞ༗͢Εɺ࣮ͨ͠6*ͷ ϑΟʔυόοΫΛಘ͍͢ ΞχϝʔγϣϯάϥϑͳͲɺσβΠϯΧϯϓͷΈ Ͱදݱ͕͍͠6*ͰޮՌత σβΠϯ࣮ͷαΠΫϧΛΑΓૣ͘ճ͢͜ͱ͕Ͱ
͖Δ
Tips: How to deploy Storybook build-storybook ίϚϯυͰ੩తαΠτग़ྗ (JU)VC1BHFT4ɺ$JSDMF$*"SUJGBDUTʹΞοϓϩʔυ
# .circleci/config.yml - run: yarn run build-storybook -o /tmp/storybook - store_artifacts: path: /tmp/storybook
As CircleCI artifacts
3. Improve unit testing
BTW, How to test view?
What should we assert? <template> <div class="greeting"> <div v-if="lang==='en'"> Good
evening, {{name}}. </div> <div class="fr" v-if="lang==='fr'"> Bon soir, {{name}}! </div> </div> </template> <template> <div class="greeting"> <div v-if="lang==='en'"> Good evening, {{name}}. </div> <div class="fr" v-if="lang==='fr'"> Bon soir, {{name}}! </div> </div> </template>
What should we assert? <template> <div class="greeting"> <div v-if="lang==='en'"> Good
evening, {{name}}. </div> <div class="fr" v-if="lang==='fr'"> Bon soir, {{name}}! </div> </div> </template> <template> <div class="greeting"> <div v-if="lang==='en'"> Good evening, {{name}}. </div> <div class="fr" v-if="lang==='fr'"> Bon soir, {{name}}! </div> </div> </template> assert.equal(node.textContents, ‘Bon soir Quramy!’) assert(node.hasClass(‘fr’)) assert.equal(node.nodeName, ’div’)
Does the test make sense…? %0.ͷΞαʔγϣϯෆໟʹͳΓ͕ͪ ʮEJWλάͰ͋Δ͜ͱʯΛ͔֬Ίͯҙຯͳ͍ ͰʮϨϯμϦϯά͞Εͨ͜ͱʯݕূ͍ͨ͠
Կؾͳ͍༷มߋ͕ΞαʔγϣϯΛই͚ͭͯ͠·͏ ࠷ѱͳͷςετΛॻ͘श׳͕ແ͘ͳͬͯ͠·͏͜ͱ
So, snapshot testing
Snapshot testing ςετ݁Ռ 4OBQTIPU Λʮਖ਼͍݁͠Ռʯͱͯ͠อଘ ࣍ճςετ࣌ʹલճ݁ՌͱͷࠩΛݕࠪ͢Δ The latest
snapshot (DOM String) The actual snapshot (DOM String) Update if snapshot is accepted Assertion
Snapshot with Jest import React from 'react'; import Link from
'../Link.react'; import renderer from 'react-test-renderer'; it('renders correctly', () => { const tree = renderer .create(<Link page="http://www.facebook.com">Facebook</Link>) .toJSON(); expect(tree).toMatchSnapshot(); });
Snapshot with Jest & Storybook ެࣜΞυΦϯ4UPSZTIPUT ॻ͍ͨTUPSJFT͕ͦͷ··ςετʹͳΔศརͳࢠ
֤TUPSZΛ+FTUͷςετέʔεͱͯ͠ɺ ࣗಈతʹεφοϓγϣοτςετΛ࣮ߦͯ͘͠ΕΔ
Workflow with Storyshots ίϯϙʔωϯτͷग़ྗ %0. ʹมߋ͕ͳ͍έʔε લճͷεφοϓγϣοτͱࠓճͷεφοϓγϣοτ ʹ͕ࠩੜ͡ͳ͍ͨΊɺςετ0,
Workflow with Storyshots ίϯϙʔωϯτͷग़ྗ %0. ʹมߋ͕͋Δέʔε εφοϓγϣοτʹ͕ࠩੜ͡ɺςετࣦഊ͢Δ
Workflow with Storyshots εφοϓγϣοτϑΝΠϧΛߋ৽ͯ͠ɺ 13ͷϒϥϯνʹؚΊΔ ϨϏϡΞʔɺมߋ͞ΕͨεφοϓγϣοτϑΝΠϧ ؚΊͯϨϏϡʔΛߦ͏
ҙਤ͠ͳ͍มߋ͕͋Δ߹ϨϏϡʔͰغ٫͢Δ
Tips: Coverage 4UPSZTIPUT7JFXͷΧόϨοδऔಘͯ͘͠ΕΔ
Furthermore: Screenshot test 4UPSZCPPLͰը૾ճؼςετ '0-*0Ͱະணख 4UPSZCPPLͱSFHTVJUͰؾܰʹ͡ΊΔ7JTVBM 3FHSFTTJPO5FTUJOH
https://blog.wadackel.me/2018/storybook-chrome-screenshot-with-reg-viz/ 4DSFFOTIPUUFTUJOHXJUI3FBDUBOE4UPSZCPPL https://medium.com/bleeding-edge/screenshot-testing-with-react-and- storybook-19ab7e49ec92
Summary
Storybook provides ίϯϙʔωϯτΛαΫαΫ࡞ΕΔڥ ࣮ࡍʹʮಈ͘ʯ6*ΛνʔϜશମʹڞ༗ ͦͷ··7JFXͷςετج൫ͱͯ͑͠Δ
What’s important ಋೖʹΑΔෆརӹ͕Ͳ͜ʹແ͍ ʮςετॻ͚ʂʯͰॻ͍ͯ͘ΕΕۤ࿑͠ͳ͍ ؾ͍ͮͨΒςετʹͳͬͯɺଞͷϝϯόʔتΜͰ͘ ΕΔͬͯɺ࠷ߴ͡Όͳ͍Ͱ͔͢ʁ
Appendix ࣮4UPSZCPPLΛಋೖͨ͠ͷൺֱత࠷ۙ 5; ͓Αͦϲ݄ͰͲͷఔΘΕ͍ͯΔ͔ d4UPSJFT
$PWFSBHF
Storybook is a development environment for UI components. https://github.com/storybooks/storybook
Thank you! By @Quramy