Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥
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
820
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
780
Créez votre propre fond de plan à partir de données OSM en utilisant TileMill
makinacorpus
0
140
Team up Django and Web mapping - DjangoCon Europe 2014
makinacorpus
3
890
Petit déjeuner "Les bases de la cartographie sur le Web"
makinacorpus
0
430
Petit déjeuner "Développer sur le cloud, ou comment tout construire à partir de rien" le 11 février - Toulouse
makinacorpus
0
280
CoDe, le programme de développement d'applications mobiles de Makina Corpus
makinacorpus
0
120
Petit déjeuner "Alternatives libres à GoogleMaps" du 11 février 2014 - Nantes - Sylvain Beorchia
makinacorpus
0
670
Petit déjeuner "Les nouveautés de la cartographie en ligne" du 12 décembre
makinacorpus
1
390
Alternatives libres à Google Maps
makinacorpus
2
3k
Other Decks in Technology
See All in Technology
事業の財務責任に向き合うリクルートデータプラットフォームのFinOps
recruitengineers
PRO
2
180
コンテキスト情報を活用し個社最適化されたAI Agentを実現する4つのポイント
kworkdev
PRO
1
1.8k
Agent Skillsがハーネスの垣根を超える日
gotalab555
5
3.5k
Oracle Database@Azure:サービス概要のご紹介
oracle4engineer
PRO
2
180
【U/Day Tokyo 2025】Cygames流 最新スマートフォンゲームの技術設計 〜『Shadowverse: Worlds Beyond』におけるアーキテクチャ再設計の挑戦~
cygames
PRO
2
1.2k
AIエージェント開発と活用を加速するワークフロー自動生成への挑戦
shibuiwilliam
4
800
まだ間に合う! Agentic AI on AWSの現在地をやさしく一挙おさらい
minorun365
17
2.3k
Amazon Bedrock Knowledge Bases × メタデータ活用で実現する検証可能な RAG 設計
tomoaki25
6
2.1k
ZOZOの独自性を生み出す「似合う4大要素」の開発サイクル
zozotech
PRO
0
120
re:Invent2025 3つの Frontier Agents を紹介 / introducing-3-frontier-agents
tomoki10
0
370
モダンデータスタックの理想と現実の間で~1.3億人Vポイントデータ基盤の現在地とこれから~
taromatsui_cccmkhd
1
240
2025-12-18_AI駆動開発推進プロジェクト運営について / AIDD-Promotion project management
yayoi_dd
0
150
Featured
See All Featured
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
57
37k
The Pragmatic Product Professional
lauravandoore
37
7.1k
Designing for Timeless Needs
cassininazir
0
89
The Spectacular Lies of Maps
axbom
PRO
1
400
The SEO Collaboration Effect
kristinabergwall1
0
300
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
196
70k
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
0
100
Bootstrapping a Software Product
garrettdimon
PRO
307
120k
Building Flexible Design Systems
yeseniaperezcruz
330
39k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
9.8k
The Language of Interfaces
destraynor
162
25k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
51k
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/