SlideShare una empresa de Scribd logo
1 de 68
Descargar para leer sin conexión
Unit and functional
testing with Siesta
Mats Bryntse, developer at Bryntum
@bryntum
Wednesday, September 25, 13
Mats Bryntse
• Ext JS developer since 2007
• Started Bryntum 2009
• Components & tools for the Sencha ecosystem
• www.bryntum.com
Wednesday, September 25, 13
Agenda
•Benefits of Siesta in your project
•Writing your first unit Siesta test
•Functional testing
•New Siesta features & improvements
Wednesday, September 25, 13
Do you test your JS?
Wednesday, September 25, 13
3 benefits of Siesta
Wednesday, September 25, 13
Unit + Functional tests
Wednesday, September 25, 13
Wednesday, September 25, 13
Wednesday, September 25, 13
A look at the Siesta
UI
Wednesday, September 25, 13
Wednesday, September 25, 13
What should I test?
Wednesday, September 25, 13
Test Model layer first
Wednesday, September 25, 13
Test Model layer first
•Easy to test, high ROI.
Wednesday, September 25, 13
Test Model layer first
•Easy to test, high ROI.
•Your.data.Model
Wednesday, September 25, 13
Test Model layer first
•Easy to test, high ROI.
•Your.data.Model
•Your.data.Store
Wednesday, September 25, 13
Test Model layer first
•Easy to test, high ROI.
•Your.data.Model
•Your.data.Store
•Your.util.Class
Wednesday, September 25, 13
Test Model layer first
•Easy to test, high ROI.
•Your.data.Model
•Your.data.Store
•Your.util.Class
•Focus on one class per test file
Wednesday, September 25, 13
Test Model layer first
•Easy to test, high ROI.
•Your.data.Model
•Your.data.Store
•Your.util.Class
•Focus on one class per test file
•Test your code, not framework code
Wednesday, September 25, 13
Ext.define(“My.model.User”, {
extend : ‘Ext.data.Model’,
fields : [‘FirstName’, ‘LastName’, ‘Salary’],
getAnnualSalary : function () {
return this.get(‘Salary’) * 12;
},
isValid : function() {
return this.get(‘FirstName’) && this.get(‘LastName’);
}
});
My.model.User
Wednesday, September 25, 13
describe(“Testing my User model”, function(t) {
t.it(‘Should get correct annual salary’, function(t) {
var user = new My.model.User({ Salary : 5000 });
t.expect(user.getAnnualSalary()).toBe(60000);
});
t.it(‘Should treat incomplete name as invalid’, function(t) {
var user = new My.model.User({ FirstName : ‘Bob’ });
t.expect(user.isValid()).toBeFalsy();
});
})
User.t.js
Wednesday, September 25, 13
StartTest(function(t) {
t.it(‘Should be able to get name’, function(t) {
var user = new My.model.User({
FirstName : ‘Bob’
});
t.expect(user.get(‘FirstName’)).toBe(‘Bob’);
});
})
Don’t test Ext JS
Wednesday, September 25, 13
var Harness = Siesta.Harness.Browser.ExtJS;
Harness.configure({
preload : [
"http://cdn.sencha.io/ext-4.2.0-gpl/resources/css/ext-all.css",
"http://cdn.sencha.io/ext-4.2.0-gpl/ext-all-debug.js",
"my-app-all-debug.js"
]
});
Harness.start({
group : 'Model Layer',
items : [
'User.t.js'
]
});
Harness.js
Wednesday, September 25, 13
Wednesday, September 25, 13
Using PhantomJS (or Selenium)
Wednesday, September 25, 13
Testing views
Wednesday, September 25, 13
Testing views
• Normally, your app consists of many view classes
Wednesday, September 25, 13
Testing views
• Normally, your app consists of many view classes
• Test your components in isolation:
Wednesday, September 25, 13
Testing views
• Normally, your app consists of many view classes
• Test your components in isolation:
• My.app.UserList
Wednesday, September 25, 13
Testing views
• Normally, your app consists of many view classes
• Test your components in isolation:
• My.app.UserList
• My.app.OrderForm
Wednesday, September 25, 13
Testing views
• Normally, your app consists of many view classes
• Test your components in isolation:
• My.app.UserList
• My.app.OrderForm
• Test your public config properties + API
Wednesday, September 25, 13
Testing views
• Normally, your app consists of many view classes
• Test your components in isolation:
• My.app.UserList
• My.app.OrderForm
• Test your public config properties + API
• Sanity tests give you peace of mind
Wednesday, September 25, 13
http://github.com/matsbryntse
Wednesday, September 25, 13
10 Sanity tests
Wednesday, September 25, 13
10 Sanity tests
1. Your namespace is created, global variable leaks.
Wednesday, September 25, 13
10 Sanity tests
1. Your namespace is created, global variable leaks.
2. Your component can be loaded on demand
Wednesday, September 25, 13
10 Sanity tests
1. Your namespace is created, global variable leaks.
2. Your component can be loaded on demand
3. No global Ext JS overrides
Wednesday, September 25, 13
10 Sanity tests
1. Your namespace is created, global variable leaks.
2. Your component can be loaded on demand
3. No global Ext JS overrides
4. Basic JsHint rules
Wednesday, September 25, 13
10 Sanity tests
1. Your namespace is created, global variable leaks.
2. Your component can be loaded on demand
3. No global Ext JS overrides
4. Basic JsHint rules
5. It does not use global style rules ('.x-panel' etc)
Wednesday, September 25, 13
10 Sanity tests
1. Your namespace is created, global variable leaks.
2. Your component can be loaded on demand
3. No global Ext JS overrides
4. Basic JsHint rules
5. It does not use global style rules ('.x-panel' etc)
6. It can be sub-classed
Wednesday, September 25, 13
10 Sanity tests
1. Your namespace is created, global variable leaks.
2. Your component can be loaded on demand
3. No global Ext JS overrides
4. Basic JsHint rules
5. It does not use global style rules ('.x-panel' etc)
6. It can be sub-classed
7. It does not leak any additional components or DOM
Wednesday, September 25, 13
10 Sanity tests
1. Your namespace is created, global variable leaks.
2. Your component can be loaded on demand
3. No global Ext JS overrides
4. Basic JsHint rules
5. It does not use global style rules ('.x-panel' etc)
6. It can be sub-classed
7. It does not leak any additional components or DOM
8. It doesn't override any private Ext JS methods
Wednesday, September 25, 13
10 Sanity tests
1. Your namespace is created, global variable leaks.
2. Your component can be loaded on demand
3. No global Ext JS overrides
4. Basic JsHint rules
5. It does not use global style rules ('.x-panel' etc)
6. It can be sub-classed
7. It does not leak any additional components or DOM
8. It doesn't override any private Ext JS methods
9. It can be created, destroyed
Wednesday, September 25, 13
10 Sanity tests
1. Your namespace is created, global variable leaks.
2. Your component can be loaded on demand
3. No global Ext JS overrides
4. Basic JsHint rules
5. It does not use global style rules ('.x-panel' etc)
6. It can be sub-classed
7. It does not leak any additional components or DOM
8. It doesn't override any private Ext JS methods
9. It can be created, destroyed
10. It passes a basic monkey test
Wednesday, September 25, 13
Functional testing
Wednesday, September 25, 13
Functional testing
• Interacting with the UI as a real user
Wednesday, September 25, 13
Functional testing
• Interacting with the UI as a real user
• Hard to solve w/ tools focusing on raw DOM/HTML.
Wednesday, September 25, 13
Functional testing
• Interacting with the UI as a real user
• Hard to solve w/ tools focusing on raw DOM/HTML.
• Siesta allows you to simulate user interactions:
Wednesday, September 25, 13
Functional testing
• Interacting with the UI as a real user
• Hard to solve w/ tools focusing on raw DOM/HTML.
• Siesta allows you to simulate user interactions:
• type
Wednesday, September 25, 13
Functional testing
• Interacting with the UI as a real user
• Hard to solve w/ tools focusing on raw DOM/HTML.
• Siesta allows you to simulate user interactions:
• type
• click
Wednesday, September 25, 13
Functional testing
• Interacting with the UI as a real user
• Hard to solve w/ tools focusing on raw DOM/HTML.
• Siesta allows you to simulate user interactions:
• type
• click
• drag
Wednesday, September 25, 13
Query Power
Wednesday, September 25, 13
Query Power
- CSS Query “.x-btn”
Wednesday, September 25, 13
Query Power
- CSS Query “.x-btn”
- Component Query “>>button”
Wednesday, September 25, 13
Query Power
- CSS Query “.x-btn”
- Component Query “>>button”
- Composite Query “gridpanel => .x-grid-cell”
Wednesday, September 25, 13
Targeting demo
Wednesday, September 25, 13
Siesta news
Wednesday, September 25, 13
Siesta news
•2.0: New User Interface
Wednesday, September 25, 13
Siesta news
•2.0: New User Interface
•Auto-scroll element into view
Wednesday, September 25, 13
Siesta news
•2.0: New User Interface
•Auto-scroll element into view
•Assertion detecting global Ext JS overrides
Wednesday, September 25, 13
Siesta news
•2.0: New User Interface
•Auto-scroll element into view
•Assertion detecting global Ext JS overrides
•Assertion to detect unnecessary layouts
Wednesday, September 25, 13
Siesta news
•2.0: New User Interface
•Auto-scroll element into view
•Assertion detecting global Ext JS overrides
•Assertion to detect unnecessary layouts
•Code coverage
Wednesday, September 25, 13
Siesta.next
Wednesday, September 25, 13
Siesta.next
•UI Localization, Japanese translation
Wednesday, September 25, 13
Siesta.next
•UI Localization, Japanese translation
•Guides + blog posts
Wednesday, September 25, 13
Siesta.next
•UI Localization, Japanese translation
•Guides + blog posts
•Test recorder
Wednesday, September 25, 13
Siesta.next
•UI Localization, Japanese translation
•Guides + blog posts
•Test recorder
Wednesday, September 25, 13
Recorder demo
Wednesday, September 25, 13
Questions?
Wednesday, September 25, 13

Más contenido relacionado

La actualidad más candente

Intro to JavaScript Testing
Intro to JavaScript TestingIntro to JavaScript Testing
Intro to JavaScript Testing
Ran Mizrahi
 
Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)
Ran Mizrahi
 

La actualidad más candente (20)

Testing ASP.NET - Progressive.NET
Testing ASP.NET - Progressive.NETTesting ASP.NET - Progressive.NET
Testing ASP.NET - Progressive.NET
 
Efficient JavaScript Unit Testing, May 2012
Efficient JavaScript Unit Testing, May 2012Efficient JavaScript Unit Testing, May 2012
Efficient JavaScript Unit Testing, May 2012
 
Javascript Test Automation Workshop (21.08.2014)
Javascript Test Automation Workshop (21.08.2014)Javascript Test Automation Workshop (21.08.2014)
Javascript Test Automation Workshop (21.08.2014)
 
Automation Abstraction Layers: Page Objects and Beyond
Automation Abstraction Layers: Page Objects and BeyondAutomation Abstraction Layers: Page Objects and Beyond
Automation Abstraction Layers: Page Objects and Beyond
 
Survive JavaScript - Strategies and Tricks
Survive JavaScript - Strategies and TricksSurvive JavaScript - Strategies and Tricks
Survive JavaScript - Strategies and Tricks
 
How to make Ajax work for you
How to make Ajax work for youHow to make Ajax work for you
How to make Ajax work for you
 
Selenium bootcamp slides
Selenium bootcamp slides   Selenium bootcamp slides
Selenium bootcamp slides
 
Intro to JavaScript Testing
Intro to JavaScript TestingIntro to JavaScript Testing
Intro to JavaScript Testing
 
JavaScript + Jenkins = Winning!
JavaScript + Jenkins = Winning!JavaScript + Jenkins = Winning!
JavaScript + Jenkins = Winning!
 
Painless JavaScript Testing with Jest
Painless JavaScript Testing with JestPainless JavaScript Testing with Jest
Painless JavaScript Testing with Jest
 
Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)
 
Unit Testing JavaScript Applications
Unit Testing JavaScript ApplicationsUnit Testing JavaScript Applications
Unit Testing JavaScript Applications
 
High Performance JavaScript - jQuery Conference SF Bay Area 2010
High Performance JavaScript - jQuery Conference SF Bay Area 2010High Performance JavaScript - jQuery Conference SF Bay Area 2010
High Performance JavaScript - jQuery Conference SF Bay Area 2010
 
Ran Mizrahi - Symfony2 meets Drupal8
Ran Mizrahi - Symfony2 meets Drupal8Ran Mizrahi - Symfony2 meets Drupal8
Ran Mizrahi - Symfony2 meets Drupal8
 
Automated php unit testing in drupal 8
Automated php unit testing in drupal 8Automated php unit testing in drupal 8
Automated php unit testing in drupal 8
 
The DOM is a Mess @ Yahoo
The DOM is a Mess @ YahooThe DOM is a Mess @ Yahoo
The DOM is a Mess @ Yahoo
 
Testing in AngularJS
Testing in AngularJSTesting in AngularJS
Testing in AngularJS
 
Webdriver cheatsheets summary
Webdriver cheatsheets summaryWebdriver cheatsheets summary
Webdriver cheatsheets summary
 
Building a JavaScript Library
Building a JavaScript LibraryBuilding a JavaScript Library
Building a JavaScript Library
 
How do I write Testable Javascript so I can Test my CF API on Server and Client
How do I write Testable Javascript so I can Test my CF API on Server and ClientHow do I write Testable Javascript so I can Test my CF API on Server and Client
How do I write Testable Javascript so I can Test my CF API on Server and Client
 

Similar a Unit and functional testing with Siesta

Intro to PHP Testing
Intro to PHP TestingIntro to PHP Testing
Intro to PHP Testing
Ran Mizrahi
 
Delivering a Responsive UI
Delivering a Responsive UIDelivering a Responsive UI
Delivering a Responsive UI
Rebecca Murphey
 
Javascript unit testing, yes we can e big
Javascript unit testing, yes we can   e bigJavascript unit testing, yes we can   e big
Javascript unit testing, yes we can e big
Andy Peterson
 
High Performance Ajax Applications 1197671494632682 2
High Performance Ajax Applications 1197671494632682 2High Performance Ajax Applications 1197671494632682 2
High Performance Ajax Applications 1197671494632682 2
Niti Chotkaew
 
High Performance Ajax Applications
High Performance Ajax ApplicationsHigh Performance Ajax Applications
High Performance Ajax Applications
Julien Lecomte
 

Similar a Unit and functional testing with Siesta (20)

Intro to PHP Testing
Intro to PHP TestingIntro to PHP Testing
Intro to PHP Testing
 
The state of JavaScript Linting - English version
The state of JavaScript Linting - English versionThe state of JavaScript Linting - English version
The state of JavaScript Linting - English version
 
Front-end development automation with Grunt
Front-end development automation with GruntFront-end development automation with Grunt
Front-end development automation with Grunt
 
iOS Development Methodology
iOS Development MethodologyiOS Development Methodology
iOS Development Methodology
 
Delivering a Responsive UI
Delivering a Responsive UIDelivering a Responsive UI
Delivering a Responsive UI
 
jQuery Mobile Deep Dive
jQuery Mobile Deep DivejQuery Mobile Deep Dive
jQuery Mobile Deep Dive
 
Javascript unit testing, yes we can e big
Javascript unit testing, yes we can   e bigJavascript unit testing, yes we can   e big
Javascript unit testing, yes we can e big
 
Einführung in AngularJS
Einführung in AngularJSEinführung in AngularJS
Einführung in AngularJS
 
Heavenly hell – automated tests at scale wojciech seliga
Heavenly hell – automated tests at scale   wojciech seligaHeavenly hell – automated tests at scale   wojciech seliga
Heavenly hell – automated tests at scale wojciech seliga
 
AD208 - End to End Quality Processes for Top Notch XPages Apps
AD208 - End to End Quality Processes for Top Notch XPages AppsAD208 - End to End Quality Processes for Top Notch XPages Apps
AD208 - End to End Quality Processes for Top Notch XPages Apps
 
Mini training - Moving to xUnit.net
Mini training - Moving to xUnit.netMini training - Moving to xUnit.net
Mini training - Moving to xUnit.net
 
Frontend Performance: Illusions & browser rendering
Frontend Performance: Illusions & browser renderingFrontend Performance: Illusions & browser rendering
Frontend Performance: Illusions & browser rendering
 
IBM ConnectED 2015 - AD302 - Responsive Application Development for XPages
IBM ConnectED 2015 - AD302 - Responsive Application Development for XPagesIBM ConnectED 2015 - AD302 - Responsive Application Development for XPages
IBM ConnectED 2015 - AD302 - Responsive Application Development for XPages
 
ZURB Foundation 5: Clean + Organized
ZURB Foundation 5: Clean + OrganizedZURB Foundation 5: Clean + Organized
ZURB Foundation 5: Clean + Organized
 
Backbone
BackboneBackbone
Backbone
 
New Methods in Automated XSS Detection & Dynamic Exploit Creation
New Methods in Automated XSS Detection & Dynamic Exploit CreationNew Methods in Automated XSS Detection & Dynamic Exploit Creation
New Methods in Automated XSS Detection & Dynamic Exploit Creation
 
SenchaCon 2016: Building a Faceted Catalog of Video Game Assets Using Ext JS ...
SenchaCon 2016: Building a Faceted Catalog of Video Game Assets Using Ext JS ...SenchaCon 2016: Building a Faceted Catalog of Video Game Assets Using Ext JS ...
SenchaCon 2016: Building a Faceted Catalog of Video Game Assets Using Ext JS ...
 
Dapper Drupal - Custom Tailored Drupal Themes
Dapper Drupal - Custom Tailored Drupal ThemesDapper Drupal - Custom Tailored Drupal Themes
Dapper Drupal - Custom Tailored Drupal Themes
 
High Performance Ajax Applications 1197671494632682 2
High Performance Ajax Applications 1197671494632682 2High Performance Ajax Applications 1197671494632682 2
High Performance Ajax Applications 1197671494632682 2
 
High Performance Ajax Applications
High Performance Ajax ApplicationsHigh Performance Ajax Applications
High Performance Ajax Applications
 

Más de Grgur Grisogono

Building Cordova plugins for iOS
Building Cordova plugins for iOSBuilding Cordova plugins for iOS
Building Cordova plugins for iOS
Grgur Grisogono
 

Más de Grgur Grisogono (18)

PRPL Pattern with Webpack and React
PRPL Pattern with Webpack and ReactPRPL Pattern with Webpack and React
PRPL Pattern with Webpack and React
 
Webpack & React Performance in 16+ Steps
Webpack & React Performance in 16+ StepsWebpack & React Performance in 16+ Steps
Webpack & React Performance in 16+ Steps
 
Back to the Future with ES.next
Back to the Future with ES.nextBack to the Future with ES.next
Back to the Future with ES.next
 
Frustration-Free Packaging of Ext JS 5 Applications
Frustration-Free Packaging of Ext JS 5 ApplicationsFrustration-Free Packaging of Ext JS 5 Applications
Frustration-Free Packaging of Ext JS 5 Applications
 
Sencha Space review
Sencha Space reviewSencha Space review
Sencha Space review
 
ModUX keynote
ModUX keynoteModUX keynote
ModUX keynote
 
Building Cordova plugins for iOS
Building Cordova plugins for iOSBuilding Cordova plugins for iOS
Building Cordova plugins for iOS
 
Practices and obstacles in agile development
Practices and obstacles in agile developmentPractices and obstacles in agile development
Practices and obstacles in agile development
 
Securing Client Side Data
 Securing Client Side Data Securing Client Side Data
Securing Client Side Data
 
Give Responsive Design a Mobile Performance Boost
Give Responsive Design a Mobile Performance BoostGive Responsive Design a Mobile Performance Boost
Give Responsive Design a Mobile Performance Boost
 
Making the Web Work on Mobile
Making the Web Work on MobileMaking the Web Work on Mobile
Making the Web Work on Mobile
 
Sencha Cmd Quick Start
Sencha Cmd Quick StartSencha Cmd Quick Start
Sencha Cmd Quick Start
 
Exploring the Possibilities of Sencha and WebRTC
Exploring the Possibilities of Sencha and WebRTCExploring the Possibilities of Sencha and WebRTC
Exploring the Possibilities of Sencha and WebRTC
 
What's Coming Next in Sencha Frameworks
What's Coming Next in Sencha FrameworksWhat's Coming Next in Sencha Frameworks
What's Coming Next in Sencha Frameworks
 
Writing High Quality Code
Writing High Quality CodeWriting High Quality Code
Writing High Quality Code
 
BlackBerry Loves the Web
BlackBerry Loves the WebBlackBerry Loves the Web
BlackBerry Loves the Web
 
Has Anyone Asked a Customer?
Has Anyone Asked a Customer?Has Anyone Asked a Customer?
Has Anyone Asked a Customer?
 
Sencha Touch Meets TYPO3 CMS
Sencha Touch Meets TYPO3 CMSSencha Touch Meets TYPO3 CMS
Sencha Touch Meets TYPO3 CMS
 

Último

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Último (20)

Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 

Unit and functional testing with Siesta

  • 1. Unit and functional testing with Siesta Mats Bryntse, developer at Bryntum @bryntum Wednesday, September 25, 13
  • 2. Mats Bryntse • Ext JS developer since 2007 • Started Bryntum 2009 • Components & tools for the Sencha ecosystem • www.bryntum.com Wednesday, September 25, 13
  • 3. Agenda •Benefits of Siesta in your project •Writing your first unit Siesta test •Functional testing •New Siesta features & improvements Wednesday, September 25, 13
  • 4. Do you test your JS? Wednesday, September 25, 13
  • 5. 3 benefits of Siesta Wednesday, September 25, 13
  • 6. Unit + Functional tests Wednesday, September 25, 13
  • 9. A look at the Siesta UI Wednesday, September 25, 13
  • 11. What should I test? Wednesday, September 25, 13
  • 12. Test Model layer first Wednesday, September 25, 13
  • 13. Test Model layer first •Easy to test, high ROI. Wednesday, September 25, 13
  • 14. Test Model layer first •Easy to test, high ROI. •Your.data.Model Wednesday, September 25, 13
  • 15. Test Model layer first •Easy to test, high ROI. •Your.data.Model •Your.data.Store Wednesday, September 25, 13
  • 16. Test Model layer first •Easy to test, high ROI. •Your.data.Model •Your.data.Store •Your.util.Class Wednesday, September 25, 13
  • 17. Test Model layer first •Easy to test, high ROI. •Your.data.Model •Your.data.Store •Your.util.Class •Focus on one class per test file Wednesday, September 25, 13
  • 18. Test Model layer first •Easy to test, high ROI. •Your.data.Model •Your.data.Store •Your.util.Class •Focus on one class per test file •Test your code, not framework code Wednesday, September 25, 13
  • 19. Ext.define(“My.model.User”, { extend : ‘Ext.data.Model’, fields : [‘FirstName’, ‘LastName’, ‘Salary’], getAnnualSalary : function () { return this.get(‘Salary’) * 12; }, isValid : function() { return this.get(‘FirstName’) && this.get(‘LastName’); } }); My.model.User Wednesday, September 25, 13
  • 20. describe(“Testing my User model”, function(t) { t.it(‘Should get correct annual salary’, function(t) { var user = new My.model.User({ Salary : 5000 }); t.expect(user.getAnnualSalary()).toBe(60000); }); t.it(‘Should treat incomplete name as invalid’, function(t) { var user = new My.model.User({ FirstName : ‘Bob’ }); t.expect(user.isValid()).toBeFalsy(); }); }) User.t.js Wednesday, September 25, 13
  • 21. StartTest(function(t) { t.it(‘Should be able to get name’, function(t) { var user = new My.model.User({ FirstName : ‘Bob’ }); t.expect(user.get(‘FirstName’)).toBe(‘Bob’); }); }) Don’t test Ext JS Wednesday, September 25, 13
  • 22. var Harness = Siesta.Harness.Browser.ExtJS; Harness.configure({ preload : [ "http://cdn.sencha.io/ext-4.2.0-gpl/resources/css/ext-all.css", "http://cdn.sencha.io/ext-4.2.0-gpl/ext-all-debug.js", "my-app-all-debug.js" ] }); Harness.start({ group : 'Model Layer', items : [ 'User.t.js' ] }); Harness.js Wednesday, September 25, 13
  • 24. Using PhantomJS (or Selenium) Wednesday, September 25, 13
  • 26. Testing views • Normally, your app consists of many view classes Wednesday, September 25, 13
  • 27. Testing views • Normally, your app consists of many view classes • Test your components in isolation: Wednesday, September 25, 13
  • 28. Testing views • Normally, your app consists of many view classes • Test your components in isolation: • My.app.UserList Wednesday, September 25, 13
  • 29. Testing views • Normally, your app consists of many view classes • Test your components in isolation: • My.app.UserList • My.app.OrderForm Wednesday, September 25, 13
  • 30. Testing views • Normally, your app consists of many view classes • Test your components in isolation: • My.app.UserList • My.app.OrderForm • Test your public config properties + API Wednesday, September 25, 13
  • 31. Testing views • Normally, your app consists of many view classes • Test your components in isolation: • My.app.UserList • My.app.OrderForm • Test your public config properties + API • Sanity tests give you peace of mind Wednesday, September 25, 13
  • 33. 10 Sanity tests Wednesday, September 25, 13
  • 34. 10 Sanity tests 1. Your namespace is created, global variable leaks. Wednesday, September 25, 13
  • 35. 10 Sanity tests 1. Your namespace is created, global variable leaks. 2. Your component can be loaded on demand Wednesday, September 25, 13
  • 36. 10 Sanity tests 1. Your namespace is created, global variable leaks. 2. Your component can be loaded on demand 3. No global Ext JS overrides Wednesday, September 25, 13
  • 37. 10 Sanity tests 1. Your namespace is created, global variable leaks. 2. Your component can be loaded on demand 3. No global Ext JS overrides 4. Basic JsHint rules Wednesday, September 25, 13
  • 38. 10 Sanity tests 1. Your namespace is created, global variable leaks. 2. Your component can be loaded on demand 3. No global Ext JS overrides 4. Basic JsHint rules 5. It does not use global style rules ('.x-panel' etc) Wednesday, September 25, 13
  • 39. 10 Sanity tests 1. Your namespace is created, global variable leaks. 2. Your component can be loaded on demand 3. No global Ext JS overrides 4. Basic JsHint rules 5. It does not use global style rules ('.x-panel' etc) 6. It can be sub-classed Wednesday, September 25, 13
  • 40. 10 Sanity tests 1. Your namespace is created, global variable leaks. 2. Your component can be loaded on demand 3. No global Ext JS overrides 4. Basic JsHint rules 5. It does not use global style rules ('.x-panel' etc) 6. It can be sub-classed 7. It does not leak any additional components or DOM Wednesday, September 25, 13
  • 41. 10 Sanity tests 1. Your namespace is created, global variable leaks. 2. Your component can be loaded on demand 3. No global Ext JS overrides 4. Basic JsHint rules 5. It does not use global style rules ('.x-panel' etc) 6. It can be sub-classed 7. It does not leak any additional components or DOM 8. It doesn't override any private Ext JS methods Wednesday, September 25, 13
  • 42. 10 Sanity tests 1. Your namespace is created, global variable leaks. 2. Your component can be loaded on demand 3. No global Ext JS overrides 4. Basic JsHint rules 5. It does not use global style rules ('.x-panel' etc) 6. It can be sub-classed 7. It does not leak any additional components or DOM 8. It doesn't override any private Ext JS methods 9. It can be created, destroyed Wednesday, September 25, 13
  • 43. 10 Sanity tests 1. Your namespace is created, global variable leaks. 2. Your component can be loaded on demand 3. No global Ext JS overrides 4. Basic JsHint rules 5. It does not use global style rules ('.x-panel' etc) 6. It can be sub-classed 7. It does not leak any additional components or DOM 8. It doesn't override any private Ext JS methods 9. It can be created, destroyed 10. It passes a basic monkey test Wednesday, September 25, 13
  • 45. Functional testing • Interacting with the UI as a real user Wednesday, September 25, 13
  • 46. Functional testing • Interacting with the UI as a real user • Hard to solve w/ tools focusing on raw DOM/HTML. Wednesday, September 25, 13
  • 47. Functional testing • Interacting with the UI as a real user • Hard to solve w/ tools focusing on raw DOM/HTML. • Siesta allows you to simulate user interactions: Wednesday, September 25, 13
  • 48. Functional testing • Interacting with the UI as a real user • Hard to solve w/ tools focusing on raw DOM/HTML. • Siesta allows you to simulate user interactions: • type Wednesday, September 25, 13
  • 49. Functional testing • Interacting with the UI as a real user • Hard to solve w/ tools focusing on raw DOM/HTML. • Siesta allows you to simulate user interactions: • type • click Wednesday, September 25, 13
  • 50. Functional testing • Interacting with the UI as a real user • Hard to solve w/ tools focusing on raw DOM/HTML. • Siesta allows you to simulate user interactions: • type • click • drag Wednesday, September 25, 13
  • 52. Query Power - CSS Query “.x-btn” Wednesday, September 25, 13
  • 53. Query Power - CSS Query “.x-btn” - Component Query “>>button” Wednesday, September 25, 13
  • 54. Query Power - CSS Query “.x-btn” - Component Query “>>button” - Composite Query “gridpanel => .x-grid-cell” Wednesday, September 25, 13
  • 57. Siesta news •2.0: New User Interface Wednesday, September 25, 13
  • 58. Siesta news •2.0: New User Interface •Auto-scroll element into view Wednesday, September 25, 13
  • 59. Siesta news •2.0: New User Interface •Auto-scroll element into view •Assertion detecting global Ext JS overrides Wednesday, September 25, 13
  • 60. Siesta news •2.0: New User Interface •Auto-scroll element into view •Assertion detecting global Ext JS overrides •Assertion to detect unnecessary layouts Wednesday, September 25, 13
  • 61. Siesta news •2.0: New User Interface •Auto-scroll element into view •Assertion detecting global Ext JS overrides •Assertion to detect unnecessary layouts •Code coverage Wednesday, September 25, 13
  • 63. Siesta.next •UI Localization, Japanese translation Wednesday, September 25, 13
  • 64. Siesta.next •UI Localization, Japanese translation •Guides + blog posts Wednesday, September 25, 13
  • 65. Siesta.next •UI Localization, Japanese translation •Guides + blog posts •Test recorder Wednesday, September 25, 13
  • 66. Siesta.next •UI Localization, Japanese translation •Guides + blog posts •Test recorder Wednesday, September 25, 13