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
eater
Search
Yosuke Furukawa
PRO
April 26, 2016
Programming
2
1.3k
eater
node 学園付属小学校の2回目で話した eater の話です。
Yosuke Furukawa
PRO
April 26, 2016
Tweet
Share
More Decks by Yosuke Furukawa
See All by Yosuke Furukawa
Node.js, Deno, Bun 最新動向とその所感について
yosuke_furukawa
PRO
7
3.5k
Welcome JSConf.jp 2024
yosuke_furukawa
PRO
1
4k
tc39 x jsconf.jp Panel Discussion 2024
yosuke_furukawa
PRO
0
220
Removing Corepack
yosuke_furukawa
PRO
9
1.6k
JavaScript Runtime とはなにか
yosuke_furukawa
PRO
15
2.8k
Strip Types と Storage
yosuke_furukawa
PRO
4
400
Module Harmony について
yosuke_furukawa
PRO
3
1.7k
LTのやり方
yosuke_furukawa
PRO
16
2.6k
AppRouter Panel Talk
yosuke_furukawa
PRO
3
800
Other Decks in Programming
See All in Programming
Duke on CRaC with Jakarta EE
ivargrimstad
1
700
バリデーションライブラリ徹底比較
nayuta999999
1
410
テスト分析入門/Test Analysis Tutorial
goyoki
11
2.7k
技術懸念に立ち向かい 法改正を穏便に乗り切った話
pop_cashew
0
590
漸進。
ssssota
0
900
「MCPを使ってる人」が より詳しくなるための解説
yamaguchidesu
0
570
RubyKaigi Hack Space in Tokyo & 函館最速 "予習" 会 / RubyKaigi Hack Space in Tokyo & The Fastest Briefing of RubyKaigi 2026 in Hakodate
moznion
1
120
AIにコードを生成するコードを作らせて、再現性を担保しよう! / Let AI generate code to ensure reproducibility
yamachu
7
6k
TypeScript Language Service Plugin で CSS Modules の開発体験を改善する
mizdra
PRO
3
2.3k
AI Coding Agent Enablement in TypeScript
yukukotani
17
7k
Design Pressure
hynek
0
1.4k
Doma で目指す ORM 最適解
nakamura_to
1
160
Featured
See All Featured
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
Product Roadmaps are Hard
iamctodd
PRO
53
11k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
42
2.3k
Gamification - CAS2011
davidbonilla
81
5.3k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.6k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
48
5.4k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
32
5.8k
Fantastic passwords and where to find them - at NoRuKo
philnash
51
3.2k
Being A Developer After 40
akosma
91
590k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
106
19k
Keith and Marios Guide to Fast Websites
keithpitt
411
22k
Transcript
Eater @yosuke_furukawa
@yosuke_furukawa
Hello, Noders. This is Full-time Papa committer
None
child_process.spawn()
None
Node Quiz
Quiz: child_process API ͷԼهͷ ҧ͍ԿͰ͠ΐ͏ 1. exec 2. spawn 3.
fork
A: spawn ͕Ұ൪ϩʔϨϕϧ exec/fork spawn ͷ wrapper
A: exec callback Ͱड͚Δɺ fork JavaScript ͷίʔυ Λ
Node.js ͱͯ͠࠶࣮ߦ͢Δ
child_process.spawn const spawn = require('child_process').spawn; const ls = spawn('ls', [‘-al']);
ls.stdout.on('data', (data) => { console.log(data); }); ls.stderr.on('data', (data) => { console.log(data); }); ls.on('exit', (code) => { if (code !== 0) console.error(`Error occurred`); });
child_process.exec const exec = require('child_process').exec; exec(‘ls -al‘, (err, stdout, stderr)
=> { console.log(`${stdout}`); console.error(`${stderr}`); if (error !== null) { console.error(`Error occurred`); } });
child_process.fork const fork = require('child_process').fork; const ls = fork(‘ls.js’); ls.stdout.on('data',
(data) => { console.log(data); }); ls.stderr.on('data', (data) => { console.log(data); }); ls.on('exit', (code) => { if (code !== 0) console.error(`Error occurred`); });
spawn > exec ͜ͷॱͰ simple exec > spawn ͜ͷॱͰ easy
spawn > fork ͜ͷॱͰ simple fork > spawn ͜ͷॱͰ easy
Easy / Simple ͷҧ͍
None
Simple !== Easy
Simple is “୯७” ٬؍తɺҰͭͷࣄ͔͠͠ͳ͍
Easy is “؆୯” ओ؍తɺ”୭͔”ʹͱͬͯ؆୯ “୭ʹͱͬͯ؆୯” ଘࡏ͠ͳ͍
ॳ৺ऀ͕ؕΓ͕ͪͳࣄɿ Easy ͷݴ༿ʹὃ͞Ε͕ͪ ୭ʹͱͬͯEasy ͳΜͯ͋Γ ͑ͳ͍
ॳ৺ऀ͕ؕΓ͕ͪͳࣄɿ Simple ͱ Easy Λࠞಉ͍ͯ͠ Δʹࠔ͞Ε͕ͪ
Eater
Eater is *Ea*sy *t*est runn*er*
Eater has one simple rule If test file outputs `stderr`
message, the test failed.
Easy => ୭ʹͱͬͯʁ `node` ͔͠Βͳ͍Α͏ͳਓ mocha/jestͷࡉ͔͍ߏจΛ֮ ͑ͯͳͯ͘ɺnode ίϚϯυ ͰεΫϦϓτͱ࣮ͯ͠ߦ͢Δ ͚ͩͰΠφϑͳਓ
Eaterͷtest script `node` command Ͱ࣮ߦͰ͖Δ
Easy => ୭ʹͱͬͯʁ mock/spyΛଟ༻͢Δ͚Ͳɺ mock/spyͷ։์࿙ΕΛΕ ͕ͪͳਓʹͱͬͯ
EaterͷtestҰͭҰ͕ͭผϓ ϩηεͰ࣮ߦ͞ΕΔ
mockΛ։์͠ͳͯ͘OK // you don’t need to fix mock/spy console.log =>
(message) { assert(message.match(/Foo Bar/)); }; const mockDate = new Date(2016, 3, 9); Date.now = () => { return mockDate.valueOf(); }; process.exit => (exitcode) { assert(exitcode === 1); };
͔͠ϓϩηείΞͰ ಄ଧͪʹͳΔ eater ——procs 4 ※procs optionͰՄม
Eater DEMO https://github.com/yosuke- furukawa/eater-demo
Happy Eater https://github.com/yosuke- furukawa/eater