Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
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
130
Team up Django and Web mapping - DjangoCon Europe 2014
makinacorpus
3
880
Petit déjeuner "Les bases de la cartographie sur le Web"
makinacorpus
0
420
Petit déjeuner "Développer sur le cloud, ou comment tout construire à partir de rien" le 11 février - Toulouse
makinacorpus
0
270
CoDe, le programme de développement d'applications mobiles de Makina Corpus
makinacorpus
0
110
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
バグハンター視点によるサプライチェーンの脆弱性
scgajge12
2
440
ML PM Talk #1 - ML PMの分類に関する考察
lycorptech_jp
PRO
1
490
.NET 10 のパフォーマンス改善
nenonaninu
2
4.7k
知っていると得する!Movable Type 9 の新機能を徹底解説
masakah
0
200
Introduction to Sansan, inc / Sansan Global Development Center, Inc.
sansan33
PRO
0
2.9k
著者と読み解くAIエージェント現場導入の勘所 Lancers TechBook#2
smiyawaki0820
7
2.8k
Security Diaries of an Open Source IAM
ahus1
0
110
Master Dataグループ紹介資料
sansan33
PRO
1
4k
Sansan Engineering Unit 紹介資料
sansan33
PRO
1
3.3k
ページの可視領域を算出する方法について整理する
yamatai1212
0
160
私のRails開発環境
yahonda
0
180
Databricksによるエージェント構築
taka_aki
1
120
Featured
See All Featured
Reflections from 52 weeks, 52 projects
jeffersonlam
355
21k
How to Think Like a Performance Engineer
csswizardry
28
2.3k
Stop Working from a Prison Cell
hatefulcrawdad
273
21k
Visualization
eitanlees
150
16k
What’s in a name? Adding method to the madness
productmarketing
PRO
24
3.8k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
34
2.5k
The Invisible Side of Design
smashingmag
302
51k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
31
2.7k
A better future with KSS
kneath
240
18k
The Cost Of JavaScript in 2023
addyosmani
55
9.3k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
1.6k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
36
6.2k
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/