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
Tests carto avec Mocha
Search
Makina Corpus
November 23, 2013
Technology
840
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Tests carto avec Mocha
Quelques notes sur le test d'applications cartographiques avec Leaflet et Mocha
Makina Corpus
November 23, 2013
More Decks by Makina Corpus
See All by Makina Corpus
Publier vos données sur le Web - Forum TIC de l'ATEN 2014
makinacorpus
0
840
Créez votre propre fond de plan à partir de données OSM en utilisant TileMill
makinacorpus
0
150
Team up Django and Web mapping - DjangoCon Europe 2014
makinacorpus
3
910
Petit déjeuner "Les bases de la cartographie sur le Web"
makinacorpus
0
460
Petit déjeuner "Développer sur le cloud, ou comment tout construire à partir de rien" le 11 février - Toulouse
makinacorpus
0
300
CoDe, le programme de développement d'applications mobiles de Makina Corpus
makinacorpus
0
130
Petit déjeuner "Alternatives libres à GoogleMaps" du 11 février 2014 - Nantes - Sylvain Beorchia
makinacorpus
0
690
Petit déjeuner "Les nouveautés de la cartographie en ligne" du 12 décembre
makinacorpus
1
410
Alternatives libres à Google Maps
makinacorpus
2
3.1k
Other Decks in Technology
See All in Technology
そのドキュメント、自動化しませんか?
yuksew
1
440
ここは地獄!つらい朝会を体験することで、チームとしてのより良い振る舞いに気づくワークショップ / The stand-up meeting from hell in the game industry
scrummasudar
0
340
Git 研修【MIXI 26新卒技術研修】
mixi_engineers
PRO
1
440
コンテナ・K8s研修【MIXI 26新卒技術研修】#2
mixi_engineers
PRO
1
200
AI x 開発生産性を取り巻く予算戦略と投資対効果
i35_267
7
3.4k
OPENLOGI Company Profile for engineer
hr01
1
75k
GoでCコンパイラを作った話
repunit
0
160
ダッシュボード"開発"について 〜使われるダッシュボードのつくりかた〜
kimichan
0
230
データエンジニアリングとドメイン駆動設計
masuda220
PRO
14
2.7k
AI時代におけるエンジニアの新たな役割──FDEとクオリアの探求/登壇資料(戸井田 裕貴)
hacobu
PRO
0
470
データ活用研修 データマネジメント【MIXI 26新卒技術研修】
mixi_engineers
PRO
2
440
Jitera Company Deck
jitera
0
570
Featured
See All Featured
How to Think Like a Performance Engineer
csswizardry
28
2.7k
Embracing the Ebb and Flow
colly
88
5.1k
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
410
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
470
The Cult of Friendly URLs
andyhume
79
7k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
340
The SEO Collaboration Effect
kristinabergwall1
1
510
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
430
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
500
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.7k
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
1
2.1k
Transcript
Tests carto avec Mocha (notes) Mathieu Leplatre @leplatrem www.makina-corpus.com
Mécanique cartographique... • →JS + DOM • <img> (Fonds de
carte) • Lat/Long pixels → (SVG, CSS) • Événements (interactions)
Mocha + PhantomJS • Browser + Command-line (headless) • Intégration
Continue (exit codes) • TDD (watch / inotify) • jsdom... $ mocha-phantomjs test/index.html <script> (window.mochaPhantomJS || window.mocha).run(); </script>
À peu près pas loin ? • 10e-9 degré ~
1mm • assert.closeTo() (Chai) ✖ 1 of 46 tests failed: 1) Locate click on line: 4: expected 0.5 to equal 0.5000000000000001 at file:///home/user/app/node_modules/chai/chai.js:401 render events
Déclencher des vrais événements • Clic | Clavier | Scroll
| Touch • createEvent API (jQuery) • happen (http://macwright.org/happen/) it('zooms-in with double click', function(done) { map.on('zoomend', function () { assert.equal(map.getZoom(), 1); done(); }); happen.dblclick(map._container); })
Contrôle du temps, Doc ! • Sinon.JS (spy + stub
+ mock + sandbox) var clock = sinon.useFakeTimers(), callback = sinon.spy(); map.on('debounced', callback); map.fire('mousemove', {latlng: [0, 0]}); clock.tick(500); map.fire('mousemove', {latlng: [0, 0]}); map.fire('mousemove', {latlng: [0, 0]}); assert.equal(2, callback.callCount);
Conclusion • Unitaires ! • « Tout est difficile avant
d'être simple. » – Thomas Fuller
Merci FranceJS & Makina Corpus ! Outils • http://leafletjs.com •
http://visionmedia.github.io/mocha/ • https://github.com/metaskills/mocha-phantomjs • http://macwright.org/happen/ • http://chaijs.com/ • http://sinonjs.org/ • https://github.com/tmpvar/jsdom Lectures • http://blog.mathieu-leplatre.info/test-your-leaflet-applications-with-mocha.html • https://nicolas.perriault.net/code/2013/testing-frontend-javascript-code-using-mocha-chai-and-sinon/