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

PuppeteerをE2Eテストに利用する/jsfes-2019-winter

 PuppeteerをE2Eテストに利用する/jsfes-2019-winter

E2Eテストは"遅い"や"不安定"という理由で実施を諦めていませんか?
WebDriverを使うのではなくPuppeteerを使うことで、こういった課題から解放され"速く安定した"テストを実行できるようになります。また、新しい評価軸でのテストもできるようになります。このセッションではE2EテストにPuppeteerを使うメリットや課題について解説します。

Kenichiro Kishida

November 30, 2019
Tweet

More Decks by Kenichiro Kishida

Other Decks in Technology

Transcript

  1. ౙͷ+BWB4DSJQUࡇJOϝϯόʔζΩϟϦΞ
    ,FOJDIJSP,JTIJEB
    !TJ[VIJLP
    1VQQFUFFSΛ

    &&ςετʹར༻͢Δ

    View full-size slide

  2. ,FOJDIJSP,JTIJEB
    5PLZP +"1"/
    TJ[VIJLP!HNBJMDPN !TJ[VIJLP
    IUUQTHJUIVCDPNTJ[VIJLP
    IUUQCMPHPQFOUPLZPKQ

    View full-size slide

  3. w5FTUJOH1ZSBNJE
    w&&ςετͰ΍Δ͜ͱ
    w1VQQFUFFS
    5PEBZT

    View full-size slide

  4. w(PPHMFʹΑΔͱ
    wˋΤϯυπʔΤϯυςετ
    wˋ݁߹ςετ
    wˋ୯ମςετ
    https://testing.googleblog.com/2015/04/just-say-no-to-more-end-to-end-tests.html
    5FTUJOH1ZSBNJE

    View full-size slide

  5. &&ςετ
    ιϑτ΢ΣΞશମΛ࠷ॳ͔Β࠷ޙ·Ͱςετ͠
    ͯɺΞϓϦέʔγϣϯ͕ظ଴Ͳ͓Γʹಈ࡞͢Δ
    ͜ͱΛ֬ೝ͢Δख๏

    View full-size slide

  6. Θ͔ΔΑ͏ͰΘ͔ΒΜ

    View full-size slide

  7. https://docs.google.com/presentation/d/15gNk21rjer3xo-
    b1ZqyQVGebOp_aPvHU3YH7YnOMxtE/edit#slide=id.g437663ce1_53_98
    Quote: Google Test Automation Conference 2014 Opening Keynote

    View full-size slide

  8. https://watirmelon.blog/tag/testing-pyramid/

    View full-size slide

  9. https://watirmelon.blog/tag/testing-pyramid/

    View full-size slide

  10. &&ςετ͕ࣦഊ͢Δͱ
    w ͳΜͰࣦഊͨ͠ͷ͔Θ͔Βͳ͍ͨΊɺ

    ࣌ؒΛ͔͚ͯݪҼΛಥ͖ࢭΊΔඞཁ͕͋Δ
    w αʔόʔ͸Ͳ͏ʁ
    w σϓϩΠ͸੒ޭ͍ͯͨ͠ʁ
    w σʔλ͸͋ͬͯΔʁ
    w ςετίʔυ͸Ͳ͏ʁ
    w ϒϥ΢βͷΞοϓσʔτ͕ݪҼʁ
    w ςετ͕յΕ΍͍͢ͷʁ
    https://watirmelon.blog/tag/testing-pyramid/

    View full-size slide

  11. https://speakerdeck.com/tsuemura/kurosuburauzatesutofalsean-toan-toan

    View full-size slide

  12. https://martinfowler.com/articles/practical-test-pyramid.html

    View full-size slide

  13. 6*ςετWT&&ςετ
    w 6*ςετͱ&&ςετ͸ಉ͡΋ͷͱݴΘΕΔ͜ͱ͕͋Γ
    ·͢ɻ
    w ΞϓϦέʔγϣϯΛ&&Ͱςετ͢Δ͜ͱ͸ɺଟ͘ͷ৔
    ߹ɺ6*Λհͯ͠ςετΛ࣮ߦ͢Δ͜ͱΛҙຯ͠·͢ɻͨͩ
    ͠ɺͦͷٯ͸౰ͯ͸·Γ·ͤΜɻ
    w 6*ͷςετ͸ɺ&&Ͱߦ͏ඞཁ͸͋Γ·ͤΜɻ࢖༻͢Δ
    ςΫϊϩδʔʹԠͯ͡ɺ6*͸ɺόοΫΤϯυΛελϒΞ΢
    τͨ͠ϑϩϯτΤϯυίʔυͷϢχοτςετΛ࡞੒͢Δ
    ͷͱಉ͘͡Β͍؆୯Ͱ͢ɻ
    https://martinfowler.com/articles/practical-test-pyramid.html

    View full-size slide

  14. &&ςετͰ͸
    w ϝϯςφϯείετ͕ߴ͍ͨΊɺ&&ςετͷ਺Λ࠷খݶʹ཈
    ͑Δͱྑ͍ɻ
    w Ϣʔβʔ͕ΞϓϦέʔγϣϯͰߦ͏Ձ஋ͷߴ͍ΠϯλϥΫγϣ
    ϯɺ੡඼ͷ֩ͱͳΔՁ஋Λఆٛ͢ΔϢʔβʔδϟʔχʔΛߟ
    ͑ɺ࠷΋ॏཁͳεςοϓΛࣗಈԽ͞Εͨ&&ςετͰදݱ͢Δ
    ͱྑ͍ɻ
    w ςετϐϥϛουʹ͸ɺ͋ΒΏΔछྨͷԼҐϨϕϧͷςετ͕
    ͨ͘͞Μ͋Γ·͢ɻ͜ΕΒͷςετΛΑΓߴ͍ϨϕϧͰ܁Γฦ
    ͢ඞཁ͸͋Γ·ͤΜɻϝϯςφϯεʹଟେͳ࿑ྗΛඅ΍͠ɺଟ
    ͘ͷޡݕग़Λߦ͏ͱɺ஗͘ͳΓɺςετͷ৴པΛࣦ͍·͢
    https://martinfowler.com/articles/practical-test-pyramid.html

    View full-size slide

  15. &&ͰධՁ͢Δ͜ͱΛఆٛ͢Δ
    w ॏཁͳγφϦΦͱεςοϓ
    w γεςϜؒ࿈ܞ
    w ύϑΥʔϚϯε
    w ʜʜʜ

    View full-size slide

  16. wϒϥ΢βࣗಈԽιϦϡʔγϣϯͰ͢ɻ
    w/PEFKT͔Β$ISPNFΛૢ࡞

    ૢΓਓܗQVQQFUFFS
    ͢ΔͨΊͷ"1*
    Λఏڙ͍ͯ͠Δɻ
    wOQNͰϒϥ΢β͕Πϯετʔϧ͞ΕΔͷ
    Ͱɺ؀ڥઃఆ΍ߏஙͷඞཁ͕ͳ͍ɻ
    wϝϞϦϦʔΫ΍ύϑΥʔϚϯεΦʔόʔ
    ϔουΛؾʹ͢Δඞཁ͕ͳ͍
    1VQQFUFFS
    https://pptr.dev/

    View full-size slide

  17. w8FCςετ͸஗͍ͱ͍͏౎ࢢ఻આ
    w#SPXTFS$POUFYU"1*Ͱղܾ
    wςετ͕'MBLZͱ͍͏౎ࢢ఻આ
    wXBJU'PS9"1*Ͱղܾ
    wͲ͜Ͱςετ͕ࣦഊ͔ͨ͠Θ͔Βͳ͍
    wDPOTPMFMPHʹԿ͔Τϥʔ͕ग़͍ͯͳ
    ͍͔νΣοΫͰ͖Δ
    ಘҙͱ͢Δͱ͜Ζ

    View full-size slide

  18. wΫϩεϒϥ΢β
    w$ISPNF͔͠࢖͑ͳ͍
    wϚϧνόʔδϣϯ
    wΠϯετʔϧ࣌όʔδϣϯͷ$ISPNF
    ͷΈ
    ۤखͳͱ͜Ζ

    View full-size slide

  19. 6*ςετΛআ͘&&ςε
    τͷ՝୊ ϥετϐʔε

    ΛຒΊΔͷͰ͸ʁ

    View full-size slide

  20. w.PCJMFσόΠεΤϛϡϨʔγϣϯ
    w0GqJOFαϙʔτ
    wαʔϏεϫʔΧʔͷݕূ
    w(FP-PDBUJPO
    w/FUXPSL.POJUPSJOH
    w,FZCPBSE.PVTF
    w1FSGPSNBODF5FTU
    w$PEF$PWFSBHF
    w"DDFTTJCJMJUZ
    ͦͷ΄͔ͷಛ௃

    View full-size slide

  21. https://chromedevtools.github.io/devtools-protocol/

    View full-size slide

  22. w+FTU͔Β1VQQFUFFSΛΑΓ؆୯ʹ࢖͑
    ΔΑ͏ʹ͢ΔϥΠϒϥϦ


    KFTUQVQQFUFFS
    https://github.com/smooth-code/jest-puppeteer

    View full-size slide

  23. 1VQQFUSZ
    https://puppetry.app/
    4FMFOJVN*%&ϥΠΫͳ+FTU1VQQFUFFSͷίʔυΛੜ੒͢Δ(6*πʔϧ

    View full-size slide

  24. wެࣜ&YBNQMF͕ࢀߟʹͳΓ·͢

    IUUQTHJUIVCDPNQVQQFUFFSFYBNQMFT
    6*ςετͰ࢖͍͍ͨ৔߹

    View full-size slide

  25. w͜Ε·Ͱ$ISPNF͚͚ͩͩͬͨͲɺ
    'JSFGPY΋࢖͑ΔΑ͏ʹͳΔΑʂ
    wݱࡏͷ"1*Λαϙʔτ
    1VQQFUFFSpSFGPY
    https://github.com/puppeteer/puppeteer/tree/master/experimental/puppeteer-
    firefox

    View full-size slide

  26. WJTJUNZCMPHHJUIVC
    https://github.com/sizuhiko
    http://blog.open.tokyo.jp

    View full-size slide