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
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
820
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
900
Petit déjeuner "Les bases de la cartographie sur le Web"
makinacorpus
0
450
Petit déjeuner "Développer sur le cloud, ou comment tout construire à partir de rien" le 11 février - Toulouse
makinacorpus
0
290
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
680
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
Data Hubグループ 紹介資料
sansan33
PRO
0
2.9k
Introduction to Sansan for Engineers / エンジニア向け会社紹介
sansan33
PRO
6
74k
基盤を育てる 外部SaaS連携の運用
gamonges_dresscode
1
120
社内エンジニア勉強会の醍醐味と苦しみ/tamadev
nishiuma
0
210
Azure Static Web Apps の自動ビルドがタイムアウトしやすくなった状況に対応した件/global-azure2026
thara0402
0
410
こんなアーキテクチャ図はいやだ / Anti-pattern in AWS Architecture Diagrams
naospon
1
450
プラットフォームエンジニアリングの実践 - AWS コンテナサービスで構築する社内プラットフォーム / AWS Containers Platform Meetup #1
literalice
1
160
Claude Code を安全に使おう勉強会 / Claude Code Security Basics
masahirokawahara
10
32k
[最強DB講義]推薦システム | 基礎編
recsyslab
PRO
1
170
Digitization部 紹介資料
sansan33
PRO
1
7.3k
Practical TypeProf: Lessons from Analyzing Optcarrot
mame
0
340
AndroidアプリとCopilot Studioの統合
nakasho
0
100
Featured
See All Featured
Producing Creativity
orderedlist
PRO
348
40k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.6k
Fireside Chat
paigeccino
42
3.9k
Evolving SEO for Evolving Search Engines
ryanjones
0
180
The World Runs on Bad Software
bkeepers
PRO
72
12k
Done Done
chrislema
186
16k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
122
21k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
1.9k
Designing for Performance
lara
611
70k
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
320
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
0
260
Balancing Empowerment & Direction
lara
6
1.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/