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
0
800
Tests carto avec Mocha
Quelques notes sur le test d'applications cartographiques avec Leaflet et Mocha
Makina Corpus
November 23, 2013
Tweet
Share
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
710
Créez votre propre fond de plan à partir de données OSM en utilisant TileMill
makinacorpus
0
120
Team up Django and Web mapping - DjangoCon Europe 2014
makinacorpus
3
840
Petit déjeuner "Les bases de la cartographie sur le Web"
makinacorpus
0
410
Petit déjeuner "Développer sur le cloud, ou comment tout construire à partir de rien" le 11 février - Toulouse
makinacorpus
0
260
CoDe, le programme de développement d'applications mobiles de Makina Corpus
makinacorpus
0
100
Petit déjeuner "Alternatives libres à GoogleMaps" du 11 février 2014 - Nantes - Sylvain Beorchia
makinacorpus
0
650
Petit déjeuner "Les nouveautés de la cartographie en ligne" du 12 décembre
makinacorpus
1
380
Alternatives libres à Google Maps
makinacorpus
2
3k
Other Decks in Technology
See All in Technology
クラウド関連のインシデントケースを収集して見えてきたもの
lhazy
5
370
株式会社Awarefy(アウェアファイ)会社説明資料 / Awarefy-Company-Deck
awarefy
3
11k
MIMEと文字コードの闇
hirachan
2
1.4k
"TEAM"を導入したら最高のエンジニア"Team"を実現できた / Deploying "TEAM" and Building the Best Engineering "Team"
yuj1osm
1
140
大規模アジャイルフレームワークから学ぶエンジニアマネジメントの本質
staka121
PRO
3
1.1k
OCI Success Journey OCIの何が評価されてる?疑問に答える事例セミナー(2025年2月実施)
oracle4engineer
PRO
2
140
AIエージェント時代のエンジニアになろう #jawsug #jawsdays2025 / 20250301 Agentic AI Engineering
yoshidashingo
8
3.6k
Exadata Database Service on Cloud@Customer セキュリティ、ネットワーク、および管理について
oracle4engineer
PRO
2
1.5k
What's new in Go 1.24?
ciarana
1
110
わたしがEMとして入社した「最初の100日」の過ごし方 / EMConfJp2025
daiksy
14
4.9k
Autonomous Database Serverless 技術詳細 / adb-s_technical_detail_jp
oracle4engineer
PRO
17
45k
データエンジニアリング領域におけるDuckDBのユースケース
chanyou0311
9
2.2k
Featured
See All Featured
Thoughts on Productivity
jonyablonski
69
4.5k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
YesSQL, Process and Tooling at Scale
rocio
172
14k
Optimising Largest Contentful Paint
csswizardry
34
3.1k
Building Adaptive Systems
keathley
40
2.4k
Large-scale JavaScript Application Architecture
addyosmani
511
110k
Building Applications with DynamoDB
mza
93
6.2k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
366
25k
RailsConf 2023
tenderlove
29
1k
Keith and Marios Guide to Fast Websites
keithpitt
411
22k
Testing 201, or: Great Expectations
jmmastey
42
7.2k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
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/