SlideShare une entreprise Scribd logo
1  sur  13
Télécharger pour lire hors ligne
1
TESTERTESTER SESSES BEHAVIORSBEHAVIORS MARIONETTE.JSMARIONETTE.JS
2
@NICOESPEON@NICOESPEON
http://nicoespeon.com
3 . 1
KEZAKOKEZAKO BEHAVIORSBEHAVIORS ??
> PETIT CHECK-UP> PETIT CHECK-UP
3 . 2
FROM ZE DOCSFROM ZE DOCS
http://marionettejs.com/docs/v2.4.3/marionette.behavior.html
“ A Behavior is an isolated set of DOM / user interactions
that can be mixed into any View or another Behavior.
“ Behaviors allow you to blackbox View-specific interactions into
portable logical chunks, keeping your Views simple and your code DRY.
3 . 3
CONCRÈTEMENTCONCRÈTEMENT
http://slides.com/stephanebachelier/marionettebehaviors#/​
Explications, implémentation et détails techniques
très bien présentés par au
meetup
Stéphane Bachelier
Backbone.js Paris S01E06
3 . 4
UN EXEMPLE PRATIQUEUN EXEMPLE PRATIQUE
4 . 1
TESTER SESTESTER SES BEHAVIORSBEHAVIORS, YAKA !, YAKA !
> LES PROBLÉMATIQUES> LES PROBLÉMATIQUES
4 . 2
PB #1 : TESTER L'API ?PB #1 : TESTER L'API ?
const Alert = Marionette.Behavior.extend( {
defaults: {
title: "Alert!",
message: "Not really urgent"
},
events: {
"click": "emitAlert"
},
emitAlert() {
alert( this.options.message );
}
} );
it( "should emit an alert", () => {
// => This won't work
expect( Behavior.emitAlert() ).toEmitAnAlert();
} );
4 . 3
PB #2 : COUPLAGE AVEC LA VUEPB #2 : COUPLAGE AVEC LA VUE
Tester une Behavior indépendamment d'une vue :
beaucoup de setup
peu de valeur ajoutée
ne vérifie pas que l'interaction
Behavior-View fonctionne bien dans notre réalité
4 . 4
PB #3 : DUPLICATION DU CODE DE TESTPB #3 : DUPLICATION DU CODE DE TEST
Tester l'interaction Behavior-View dans chaque test de vue…
5 . 1
SOLUTIONSOLUTION PROPOSÉEPROPOSÉE
https://github.com/nicoespeon/testing-marionette-behaviors
http://www.nicoespeon.com/fr/2015/11/tester-behaviors-marionette/​
5 . 2
ARTICLES SUR LA QUESTIONARTICLES SUR LA QUESTION
http://spin.atomicobject.com/2014/09/11/marionette-
behaviors-overview/
http://spin.atomicobject.com/2014/09/12/testing-
marionette-js-behaviors/
6
MERCI !MERCI ! DES QUESTIONS ?DES QUESTIONS ?

Contenu connexe

Plus de Nicolas Carlo

À la découverte des Observables - HumanTalks Paris 2017
À la découverte des Observables - HumanTalks Paris 2017À la découverte des Observables - HumanTalks Paris 2017
À la découverte des Observables - HumanTalks Paris 2017Nicolas Carlo
 
À la découverte des observables
À la découverte des observablesÀ la découverte des observables
À la découverte des observablesNicolas Carlo
 
Testing Marionette.js Behaviors
Testing Marionette.js BehaviorsTesting Marionette.js Behaviors
Testing Marionette.js BehaviorsNicolas Carlo
 
Chaining and function composition with lodash / underscore
Chaining and function composition with lodash / underscoreChaining and function composition with lodash / underscore
Chaining and function composition with lodash / underscoreNicolas Carlo
 
Les générateurs de code, pour se simplifier la vie au quotidien
Les générateurs de code, pour se simplifier la vie au quotidienLes générateurs de code, pour se simplifier la vie au quotidien
Les générateurs de code, pour se simplifier la vie au quotidienNicolas Carlo
 
Kanban et Game Development avec Trello
Kanban et Game Development avec TrelloKanban et Game Development avec Trello
Kanban et Game Development avec TrelloNicolas Carlo
 
Plop : un micro-générateur pour se simplifier la vie au quotidien
Plop : un micro-générateur pour se simplifier la vie au quotidienPlop : un micro-générateur pour se simplifier la vie au quotidien
Plop : un micro-générateur pour se simplifier la vie au quotidienNicolas Carlo
 
Chaining et composition de fonctions avec lodash / underscore
Chaining et composition de fonctions avec lodash / underscoreChaining et composition de fonctions avec lodash / underscore
Chaining et composition de fonctions avec lodash / underscoreNicolas Carlo
 
Comment organiser un gros projet backbone
Comment organiser un gros projet backboneComment organiser un gros projet backbone
Comment organiser un gros projet backboneNicolas Carlo
 

Plus de Nicolas Carlo (9)

À la découverte des Observables - HumanTalks Paris 2017
À la découverte des Observables - HumanTalks Paris 2017À la découverte des Observables - HumanTalks Paris 2017
À la découverte des Observables - HumanTalks Paris 2017
 
À la découverte des observables
À la découverte des observablesÀ la découverte des observables
À la découverte des observables
 
Testing Marionette.js Behaviors
Testing Marionette.js BehaviorsTesting Marionette.js Behaviors
Testing Marionette.js Behaviors
 
Chaining and function composition with lodash / underscore
Chaining and function composition with lodash / underscoreChaining and function composition with lodash / underscore
Chaining and function composition with lodash / underscore
 
Les générateurs de code, pour se simplifier la vie au quotidien
Les générateurs de code, pour se simplifier la vie au quotidienLes générateurs de code, pour se simplifier la vie au quotidien
Les générateurs de code, pour se simplifier la vie au quotidien
 
Kanban et Game Development avec Trello
Kanban et Game Development avec TrelloKanban et Game Development avec Trello
Kanban et Game Development avec Trello
 
Plop : un micro-générateur pour se simplifier la vie au quotidien
Plop : un micro-générateur pour se simplifier la vie au quotidienPlop : un micro-générateur pour se simplifier la vie au quotidien
Plop : un micro-générateur pour se simplifier la vie au quotidien
 
Chaining et composition de fonctions avec lodash / underscore
Chaining et composition de fonctions avec lodash / underscoreChaining et composition de fonctions avec lodash / underscore
Chaining et composition de fonctions avec lodash / underscore
 
Comment organiser un gros projet backbone
Comment organiser un gros projet backboneComment organiser un gros projet backbone
Comment organiser un gros projet backbone
 

Tester ses Behaviors Marionette.js

  • 1. 1 TESTERTESTER SESSES BEHAVIORSBEHAVIORS MARIONETTE.JSMARIONETTE.JS
  • 3. 3 . 1 KEZAKOKEZAKO BEHAVIORSBEHAVIORS ?? > PETIT CHECK-UP> PETIT CHECK-UP
  • 4. 3 . 2 FROM ZE DOCSFROM ZE DOCS http://marionettejs.com/docs/v2.4.3/marionette.behavior.html “ A Behavior is an isolated set of DOM / user interactions that can be mixed into any View or another Behavior. “ Behaviors allow you to blackbox View-specific interactions into portable logical chunks, keeping your Views simple and your code DRY.
  • 5. 3 . 3 CONCRÈTEMENTCONCRÈTEMENT http://slides.com/stephanebachelier/marionettebehaviors#/​ Explications, implémentation et détails techniques très bien présentés par au meetup Stéphane Bachelier Backbone.js Paris S01E06
  • 6. 3 . 4 UN EXEMPLE PRATIQUEUN EXEMPLE PRATIQUE
  • 7. 4 . 1 TESTER SESTESTER SES BEHAVIORSBEHAVIORS, YAKA !, YAKA ! > LES PROBLÉMATIQUES> LES PROBLÉMATIQUES
  • 8. 4 . 2 PB #1 : TESTER L'API ?PB #1 : TESTER L'API ? const Alert = Marionette.Behavior.extend( { defaults: { title: "Alert!", message: "Not really urgent" }, events: { "click": "emitAlert" }, emitAlert() { alert( this.options.message ); } } ); it( "should emit an alert", () => { // => This won't work expect( Behavior.emitAlert() ).toEmitAnAlert(); } );
  • 9. 4 . 3 PB #2 : COUPLAGE AVEC LA VUEPB #2 : COUPLAGE AVEC LA VUE Tester une Behavior indépendamment d'une vue : beaucoup de setup peu de valeur ajoutée ne vérifie pas que l'interaction Behavior-View fonctionne bien dans notre réalité
  • 10. 4 . 4 PB #3 : DUPLICATION DU CODE DE TESTPB #3 : DUPLICATION DU CODE DE TEST Tester l'interaction Behavior-View dans chaque test de vue…
  • 11. 5 . 1 SOLUTIONSOLUTION PROPOSÉEPROPOSÉE https://github.com/nicoespeon/testing-marionette-behaviors http://www.nicoespeon.com/fr/2015/11/tester-behaviors-marionette/​
  • 12. 5 . 2 ARTICLES SUR LA QUESTIONARTICLES SUR LA QUESTION http://spin.atomicobject.com/2014/09/11/marionette- behaviors-overview/ http://spin.atomicobject.com/2014/09/12/testing- marionette-js-behaviors/
  • 13. 6 MERCI !MERCI ! DES QUESTIONS ?DES QUESTIONS ?