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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
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
850
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
取引先から届く 「セキュリティチェックシート」の読み解き方
kamadamakoto
0
140
侵入は突然に 〜 IoTマルウェアと悪用される家庭の機器 ~ / When Intrusion Strikes: IoT Malware and the Abuse of Home Devices
nttcom
0
1.5k
サイバー捜査員研修(後半)
nomizone
1
810
修正PRを食べてレビュースキルが賢くなる:Claude Codeによる自己改善サイクル
yuyaumetsu
6
1.4k
【CEDEC2026】『GRANBLUE FANTASY: Relink - Endless Ragnarok』のバトル制作事例 ~最高のキャラゲーを目指して~
cygames
PRO
0
230
システム思考で問題に対処する
yussak
0
210
Breaking the Seal: Static Deobfuscation of Compiled V8 JavaScript Bytecode Malware
hshrzd
0
660
Data Hubグループ 紹介資料
sansan33
PRO
0
3.1k
【CEDEC2026】ゲームシナリオライターを支援するAIツール開発の実践 ― 設計とプロンプトの工夫 ―
cygames
PRO
1
770
【5分でわかる】セーフィー エンジニア向け会社紹介
safie_recruit
0
53k
Digitization部 紹介資料
sansan33
PRO
2
7.7k
Invisible to AI? Making TYPO3 Sites Quotable by AI Search Systems
wolfgangwagner
0
170
Featured
See All Featured
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.8k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
2.1k
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
270
SEO for Brand Visibility & Recognition
aleyda
0
4.7k
Game over? The fight for quality and originality in the time of robots
wayneb77
1
240
The Limits of Empathy - UXLibs8
cassininazir
1
600
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
Paper Plane
katiecoart
PRO
2
52k
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
200
AI Search: Where Are We & What Can We Do About It?
aleyda
0
7.8k
How to make the Groovebox
asonas
2
2.3k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
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/