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

20180125mocha.jsとbackstop.jsで大規模リニューアルのリグレッショ...

Sponsored · Ship Features Fearlessly Turn features on and off without deploys. Used by thousands of Ruby developers.

 20180125mocha.jsとbackstop.jsで大規模リニューアルのリグレッションテスト

Avatar for moyashidaisuke

moyashidaisuke

January 27, 2018

More Decks by moyashidaisuke

Other Decks in Technology

Transcript

  1. ࣗݾ঺հ • ͸͡Ί·ͯ͠ • ෱ాେཌྷʢ;͍͚ͩͩ͘͢ʣ • @moyashidaisuke • ίϩϓϥ ->

    ΈΜΕͼ • αʔόαΠυΑΓͰ͕͢ϑϩϯτ΋΍Γ· ͢ɻੲ͸jsͱcssͰΨνϟԋग़࡞ͬͨΓͯ͠ ·ͨ͠ɻ • ໨ࠇࡏॅ
  2. ઃఆϑΝΠϧ { "viewports": [ { "label": "phone", "width": 320, "height":

    480 }, { "label": "tablet", "width": 1024, "height": 768 } ], "scenarios": [ {"label": "/","url": “https://testdomain/" ,"referenceUrl": "http://obousan.minrevi.jp/"}, {"label": "/aisatsu-reibun/","url": “https://testdomain/aisatsu-reibun/", "referenceUrl": "http://obousan.minrevi.jp/aisatsu-reibun/"}, ], Ωϟϓνϟ͍ͨ͠ ը໘αΠζ ର৅ͷ63-Λྻڍ
  3. mochaͱcheerio-httpcliͰࣗ࡞ • mocha -> testingͷFW • cheerio-httpcli -> εΫϨΠϐϯά •

    ؤுͬͯεΫϨΠϐϯάͯ͠metaλάΛऔಘ͠ ͯɺassert͢Δ • େͨ͠ࣄ͍ͯ͠ͳ͍ͷͰ͋Γͦ͏Ͱແ͔ͬͨʢ͋ͬ ͨΒڭ͍͑ͯͩ͘͞ʂʣ
  4. εΫϦϓτͪΒݟͤ function getSeoData(url) { const data = {}; const result

    = client.fetchSync(url); data.title = result.$('title').text(); data.keywords = result.$('meta[name="keywords"]').attr('content'); return data; } describe(senario.url, () => { let newSeoData, oldSeoData; before(done => { newSeoData = getSeoData(newUrl); oldSeoData = getSeoData(oldUrl); done(); }); // ҎԼςετέʔε it('title', () => { assert.equal(newSeoData.title, oldSeoData.title); }); it('keywords', () => { assert.equal(newSeoData.keywords, oldSeoData.keywords); }); }); });
  5. QA