Slide 1

Slide 1 text

fly & ava Pine Mizune 8 Dec, 2015 / Meguro.es #1

Slide 2

Slide 2 text

自己紹介 o ID / HN: @pine613 o 好きな言語: JavaScript / Crystal o 仕事で書いてる: Perl / Swift / Kotlin o Mobile Factory, Inc o 最寄り: 五反田駅

Slide 3

Slide 3 text

目次 • fly とは ? • ava とは ? • ava + Promise • ava + Generator • ava + Async • ava + fly

Slide 4

Slide 4 text

• ES6 ベースの次世代ビルドシステム • 今回は詳しく説明しません – Gotanda.js #1 の発表資料参照 fly とは ? 作者: bucaran

Slide 5

Slide 5 text

• ES6/7 ベースのテストランナー • Promise, Generator, Async との相性 • Babel, co, power-assert のビルトインサポート ava とは ? 作者: sindresorhus

Slide 6

Slide 6 text

ava でのテストの書き方 import test from ‘ava’ test(‘testFunc’, t => { t.is(testFunc(result), 10) })

Slide 7

Slide 7 text

mocha + Callback var expect = require(‘chai’).expect; it(‘testFunc’, function (done) { testFunc(function (result) { expect(result).to.equal(10); done(); }); });

Slide 8

Slide 8 text

ava + Callback import test from ‘ava’ test.cb(‘testFunc’, t => { testFunc(result => { t.is(result, 10) t.end() }) })

Slide 9

Slide 9 text

mocha + Promise var expect = require(‘chai’).expect; it(‘testFunc’, function (done) { testFunc().then(function (result) { expect(result).to.equal(10); done(); }); });

Slide 10

Slide 10 text

ava + Promise import test from ‘ava’ test(‘testFunc’, t => { return testFunc().then(result => { t.is(result, 10) }) }) Promise をそのまま返せる!

Slide 11

Slide 11 text

ava + co import test from ‘ava’ test(‘testFunc’, t => { return co(function *() { const result = yield testFunc() t.is(result, 10) }) })

Slide 12

Slide 12 text

ava + Generator import test from ‘ava’ test(‘testFunc’, function *() { const result = yield testFunc() t.is(result, 10) }) Generator をそのまま返せる!

Slide 13

Slide 13 text

ava + Async import test from ‘ava’ test(‘testFunc’, async t => { const result = await testFunc() t.is(result, 10) }) async / await 対応

Slide 14

Slide 14 text

ava + fly export function* test() { this.source(‘./test/**/*.js’).ava() } $ npm install fly fly-ava ava $ fly test flyfile.js

Slide 15

Slide 15 text

告知: Gotanda.js #2 開催決定!! ü Gotanda.js #2 〜JS新年会〜 ü 日時: 2016 年 1 月 8 日 (金) ü 会場: 株式会社ガイアックス ü 内容: LT 祭!! (5min LT x 8) Ø 申し込みは Connpass から! http://gotandajs.connpass.com/event/22162/