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
830
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
810
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
440
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
Databricks Appsで実現する社内向けAIアプリ開発の効率化
r_miura
0
230
Kubernetesの「隠れメモリ消費」によるNode共倒れと、Request適正化という処方箋
g0xu
0
170
【関西電力KOI×VOLTMIND 生成AIハッカソン】空間AIブレイン ~⼤阪おばちゃんフィジカルAIに続く道~
tanakaseiya
0
110
Even G2 クイックスタートガイド(日本語版)
vrshinobi1
0
190
マルチモーダル非構造データとの闘い
shibuiwilliam
1
150
Cursor Subagentsはいいぞ
yug1224
2
130
不確実性と戦いながら見積もりを作成するプロセス/mitsumori-process
hirodragon112
1
180
FASTでAIエージェントを作りまくろう!
yukiogawa
4
190
Sansanの認証基盤を支えるアーキテクチャとその振り返り
sansantech
PRO
1
150
MIX AUDIO EN BROADCAST
ralpherick
0
140
GitHub Actions侵害 — 相次ぐ事例を振り返り、次なる脅威に備える
flatt_security
12
7.3k
Cortex Codeでデータの仕事を全部Agenticにやりきろう!
gappy50
0
220
Featured
See All Featured
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
1.9k
Into the Great Unknown - MozCon
thekraken
40
2.3k
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
1
1.5k
Marketing to machines
jonoalderson
1
5.1k
VelocityConf: Rendering Performance Case Studies
addyosmani
333
25k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.7k
WCS-LA-2024
lcolladotor
0
510
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.3k
Git: the NoSQL Database
bkeepers
PRO
432
67k
Product Roadmaps are Hard
iamctodd
PRO
55
12k
Amusing Abliteration
ianozsvald
1
150
Code Review Best Practice
trishagee
74
20k
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/