Upgrade to Pro — share decks privately, control downloads, hide ads and more …

GAS開発のJestによるモック入り結合テスト仕立て / The way to develop GAS with mocking integration test by Jest

Aqui TSUCHIDA
October 17, 2018

GAS開発のJestによるモック入り結合テスト仕立て / The way to develop GAS with mocking integration test by Jest

このスライドは
【エンジニア交流会】Google Apps Script 活用ミートアップ #3 (2018-10-17)
https://gaiax.connpass.com/event/101411/
で発表したものです。
Google App Script の開発はお手軽だけど動作確認がポチポチ面倒じゃありませんか?
Jestの強力なモック機能を駆使した結合テストを導入して、かなり楽になった知見を実例を交えてご紹介しようと思いました。

サンプルコードGist
https://gist.github.com/AquiTCD/81294f568b823e5eecca11a182a69e14

---
2019-3-8 追記

現在はWebpackではなくClasp+TypeScriptで書いています。
こちらも参考になれば嬉しいです。

Google App ScriptをTypeScriptとClass構文で書く - 環境導入
https://blog.solunita.net/lean-to-develop-google-app-script-with-typescript-class-setup/

Google App ScriptをTypeScriptとClass構文で書く - 実装
https://blog.solunita.net/lean-to-develop-google-app-script-with-typescript-class-implement/

Aqui TSUCHIDA

October 17, 2018
Tweet

More Decks by Aqui TSUCHIDA

Other Decks in Technology

Transcript

  1. ࣗݾ঺հ Aqui TSUCHIDA ౔ా ໌৴ @AquiTCD αʔόʔαΠυΤϯδχΞ at झຯ: ϑϩϯτΤϯυ։ൃ

    #ྉཧ #ےτϨ #ήʔϚʔ #ݩόοΫύοΧʔ https://aquitcd.github.io/Pentazemin/ja/ Pentazemin: Electron੡λεΫ؅ཧΞϓϦ https://aquitcd.github.io/yantan/ja/ YANTAN: Chrome֦ு Rubyist, JSer
  2. ΞδΣϯμ - ࠓ೔࿩͢͜ͱ • ςετΛՄೳʹ͢Δ؀ڥ • ࣮ࡍͷέʔεΛྫͱͯ͠঺հ • ݁߹ςετͷͨΊʹ΍Δ͜ͱ ※͜͜Ͱ͸ೖྗ͔Βग़ྗ·Ͱͷςετͱ͠·͢

    ࠓ೔࿩͞ͳ͍͜ͱ • ؀ڥߏஙͷࡉ͔͍࿩(clasp, webpackͷಋೖํ๏ͳͲʣ • JestͰͷςετίʔυͷॻ͖ํ αϯϓϧίʔυͷGist: https://gist.github.com/AquiTCD/81294f568b823e5eecca11a182a69e14
  3. Clasp is Կʁ ϩʔΧϧͰ։ൃͰ͖ΔͱԿ͕͍͍ͷʁ • Git؅ཧͰ͖Δ • Linter, Formatter͕ޮ͘ •

    ES6ͷه๏Ͱॻ͚Δ • ςετ͕ॻ͚ͯճͤΔ $ clasp push $ clasp deploy ͳͲͰຊ൪ద༻Ͱ͖ͪΌ͏ ϩʔΧϧ؀ڥͰGASΛ։ൃͰ͖ΔCLIπʔϧ = εΫϦϓτΤσΟλ಺Ͱॻ͔ͳ͍͍ͯ͘
  4. Webpack ͱ Jest • JSͷ͋Ε΍͜Ε΍ΛΨονϟϯί • ඞਢͰ͸ͳ͍ͷͰผͷπʔϧͰ΋Մ • Jest •

    facebook੡ͷςετπʔϧ • ΦʔϧΠϯϫϯ • ڧྗͳϞοΫϥΠϒϥϦΛ಺ଂ