SlideShare a Scribd company logo
Frontend automation and stability
@matenadasdi
Ustream, Inc
Common sentences from the past
Writing tests is a huge overhead
Browsers are unpredictable and we are not able to test real behaviour
Let’s write this frontend task in PHP, Ruby, Python, Bash …
Selenium is unstable and complicated
“
It’s a new ERA
Let’s ride it!
Testing
!
Trendy question:
TDD is dead?
</flame>
TDD/BDD/HDD/DVD…
It doesn’t matter,
Testing is a must in large scale!
Good news! We have everything what we need
Hundreds of tools and frameworks - Mocha, Jasmine, Jest, Karma, QUnit
Headless browsers - PhantomJS, SlimerJS, TrifleJS
Headless navigation scripting libs - CasperJS, DalekJS
Our setup at
1. Unit testing
Criterions for efficient unit testing
Separated layers with different responsibilities for easier mocking
Business Logic and the representation have to be separated
Dependency Injection
Mocha + Chai
framework:
Node and Browser support
Separate assert libraries
Tons of reporters
mocking:
SinonJS
Spies, Stubs, Mocks
Assertions for invocations
Faking AJAX, server
Works with lot of frameworks
module dependency mocking:
SquireJS
Dependency injector for RequireJS
mock / store
It’s not an overhead, easy to run and write!
Coverage?
function coverage
function epam (speaker, onStage)
{
var talking = false;
!
if (speaker && onStage){
talking = true;
}
!
return talking;
}
if epam called once, its covered
statement coverage
function epam (speaker, onStage)
{
var talking = false;
!
if (speaker && onStage){
talking = true;
}
!
return talking;
}
with testing epam(true, true),
all statement will be executed,
so its covered
branch coverage
function epam (speaker, onStage)
{
var talking = false;
!
if (speaker && onStage){
talking = true;
}
!
return talking;
}
with testing
epam(true, true), and epam (true, false)
all execution paths will be covered
Ok it’s nice, but is it possible in JS?
;)
Istanbul
https://github.com/gotwarlost/istanbul
Esprima based
statement, branch, function coverage
multiple reporters
command line support
Karma test runner
http://karma-runner.github.io/0.12/index.html
+
WebStorm integration
Istanbul code coverage support
Mocha, Jasmine, QUnit support
Jenkins, Travis support
Unit tests cannot cover everything!
Browser / DOM / Interaction specific behaviour
should be tested in a different way
2. UI testing
The genie is out of the bottle
Navigation scripting in Node
We use CasperJS
Node.js based navigation scripting
PhantomJS & SlimerJS support
screenshot capture
not necessary to use its testing framework
Pro:
phantomjs based browsers only
Cons:
This is Node, you can do everything!
Create your own modules
you can call global casper from everywhere
DalekJS is coming up!
Real browser support
Chrome, FF, IE, Mobile Safari
It can run in headless browsers too
Pro:
strict testing framework interface
small documentation and not enough methods
still developer preview (0.0.8)
Cons:
3. Test automation team
selenium, real browsers, complex features, mobile devices
4. Manual QA team
Smoke tests, regression tests, screenshot comparison tool, internal debug tools
Automation
We picked Grunt
NPM for dependency management
we could port every frontend related task to Node
we use 12 grunt plugins (2800+ available globally)
be careful, lot of tasks can lead to a huge/complex grunt file
we have an own structure for task configurations
Thanks to Grunt...
Why not Gulp?
a bad question
Node streams are awesome, but it can be hard for non-js devs
Code over configuration
713 plugins and coming up really fast
Try both, and maybe use both!
Gulp is good tool too!
Standards & Rules
!
Our previous setup was too simple
JSLint manually (!)
YuiCompressor after commits in Jenkins
Rules are not rules if you break them!
Everyone writes different code
and it’s normal
Code style! Be aggressive!
a smarter JSLint
separated configuration file
everyone can run the same config
most IDEs can read it globally
Esprima!!!!!!!!!!!!!!!!!!!!!!!!!!44
https://github.com/ariya/esprima
more possibilities with
{
"type": "Program",
"body": [{
"type": "IfStatement",
"test": {
"type": "Identifier",
"name": "epam"
},
“consequent": {
"type": "BlockStatement",
"body": [{
"type": "ExpressionStatement",
"expression": {
"type": "AssignmentExpression",
"operator": "=",
"left": {
"type": "Identifier",
"name": "conf"
},
"right": {
"type": "Literal",
"value": "SEC",
"raw": "'SEC'"
}
}
}]
},
"alternate": null
}]
var epam = true;
!
if (epam) {
conf = 'SEC';
}
Semantics & your own rules
Esprima based
pluginable
thanks to the AST it can examine semantics
Esprima based rule definitions
Complexity report
Does it matter?
Who wouldn’t wanna track these?
http://jscomplexity.org/complexity
Lines of code (LOC)
Halstead complexity measures
Maintainability index
Cyclomatic complexity
Cyclomatic complexity = E - N + 2P
linearly independent paths in the method
E = number of edges in the flow graph
N = number of nodes in the flow graph
P = number of nodes that have exit points
6 -6 + 2 = 2
JSComplexity & Plato
We run complexity report in Jenkins nightly build for our whole JS codebase
https://www.npmjs.org/package/complexity-report
Plato is a great tool for manual examinations
https://github.com/es-analysis/plato
Frontend automation and stability
CI Integration
CI can run your tools automatically and periodically
It can catch accidental commits
Nearly every grunt plugin supports .xml reporters
this 3 simple things
can lead to a more stable and scalable JS codebase
Testing Automation Standards & rules
!
Thank you!
Questions?
!
!
@matenadasdi

More Related Content

What's hot (8)

PDF
Testing Mobile JavaScript
jeresig
 
PDF
Repoze Bfg - presented by Rok Garbas at the Python Barcelona Meetup October 2...
maikroeder
 
PDF
Cucumber.js: Cuke up your JavaScript!
Julien Biezemans
 
PPTX
MelbJS Nov2014 - CommonJS & Mocking with Jest
James Hunter
 
PPTX
Java web programming
jkumaranc
 
PDF
The Real World - Plugging the Enterprise Into It (nodejs)
Aman Kohli
 
PDF
Commit Hooks: the Subtle Hammer
Ben McGraw
 
PDF
Microservices for the Masses with Spring Boot, JHipster, and JWT - Rich Web 2016
Matt Raible
 
Testing Mobile JavaScript
jeresig
 
Repoze Bfg - presented by Rok Garbas at the Python Barcelona Meetup October 2...
maikroeder
 
Cucumber.js: Cuke up your JavaScript!
Julien Biezemans
 
MelbJS Nov2014 - CommonJS & Mocking with Jest
James Hunter
 
Java web programming
jkumaranc
 
The Real World - Plugging the Enterprise Into It (nodejs)
Aman Kohli
 
Commit Hooks: the Subtle Hammer
Ben McGraw
 
Microservices for the Masses with Spring Boot, JHipster, and JWT - Rich Web 2016
Matt Raible
 

Viewers also liked (20)

PPTX
Front end Tips Tricks & Tools
Sandeep Ramgolam
 
PDF
Sinau Bareng Frontend Web Development @ DiLo Malang
Moch. Zamroni
 
PDF
Front End Tooling and Performance - Codeaholics HK 2015
Holger Bartel
 
PDF
User eXperience & Front End Development
andreafallaswork
 
PDF
Webinar: Front End Web Development - Trendy Web Designs Using HTML5
Edureka!
 
PDF
Frontend SPOF
Patrick Meenan
 
PDF
Architecting your Frontend
Ruben Teijeiro
 
PDF
建立前端开发团队 (Front-end Development Environment)
Joseph Chiang
 
PDF
Grunt js for the Enterprise Vol.1: Frontend Performance with Phantomas
David Amend
 
PDF
Wrangling Large Scale Frontend Web Applications
Ryan Roemer
 
PDF
A modern front end development workflow for Magnolia at Atlassian
Magnolia
 
PDF
How to Build Front-End Web Apps that Scale - FutureJS
Phil Leggetter
 
PPTX
Frontend technologies
Jose Ramon Roblero Ruiz
 
PPTX
W3 conf hill-html5-security-realities
Brad Hill
 
PDF
Frontend at Scale - The Tumblr Story
Chris Miller
 
PPTX
Modern Frontend Technology
Ship Hsu
 
PDF
TechTalk #85 : Latest Frontend Technologies
bincangteknologi
 
PDF
Front End Development Workflow Tools
Ahmed Elmehri
 
PDF
The Frontend Developer Landscape Explained and the Rise of Advanced Frontend ...
Prasid Pathak
 
PDF
engage 2015 - Domino App Development - Where should I go now?
René Winkelmeyer
 
Front end Tips Tricks & Tools
Sandeep Ramgolam
 
Sinau Bareng Frontend Web Development @ DiLo Malang
Moch. Zamroni
 
Front End Tooling and Performance - Codeaholics HK 2015
Holger Bartel
 
User eXperience & Front End Development
andreafallaswork
 
Webinar: Front End Web Development - Trendy Web Designs Using HTML5
Edureka!
 
Frontend SPOF
Patrick Meenan
 
Architecting your Frontend
Ruben Teijeiro
 
建立前端开发团队 (Front-end Development Environment)
Joseph Chiang
 
Grunt js for the Enterprise Vol.1: Frontend Performance with Phantomas
David Amend
 
Wrangling Large Scale Frontend Web Applications
Ryan Roemer
 
A modern front end development workflow for Magnolia at Atlassian
Magnolia
 
How to Build Front-End Web Apps that Scale - FutureJS
Phil Leggetter
 
Frontend technologies
Jose Ramon Roblero Ruiz
 
W3 conf hill-html5-security-realities
Brad Hill
 
Frontend at Scale - The Tumblr Story
Chris Miller
 
Modern Frontend Technology
Ship Hsu
 
TechTalk #85 : Latest Frontend Technologies
bincangteknologi
 
Front End Development Workflow Tools
Ahmed Elmehri
 
The Frontend Developer Landscape Explained and the Rise of Advanced Frontend ...
Prasid Pathak
 
engage 2015 - Domino App Development - Where should I go now?
René Winkelmeyer
 
Ad

Similar to Frontend automation and stability (20)

PPTX
3 Ways to test your ColdFusion API - 2017 Adobe CF Summit
Ortus Solutions, Corp
 
PDF
3 WAYS TO TEST YOUR COLDFUSION API
Gavin Pickin
 
PDF
3 WAYS TO TEST YOUR COLDFUSION API -
Ortus Solutions, Corp
 
PDF
How do I Write Testable Javascript so I can Test my CF API on Server and Client
ColdFusionConference
 
PPTX
How do I write Testable Javascript so I can Test my CF API on Server and Client
Gavin Pickin
 
PDF
Node.js Development Workflow Automation with Grunt.js
kiyanwang
 
PPTX
Java script unit testing
Mats Bryntse
 
PDF
How to write Testable Javascript
ColdFusionConference
 
PDF
How do I write Testable Javascript - Presented at dev.Objective() June 16, 2016
Gavin Pickin
 
PPTX
Testing nodejs apps
felipefsilva
 
PDF
JavaScript TDD with Jasmine and Karma
Christopher Bartling
 
PDF
JS Lab`16. Сергей Селецкий: "Ретроспектива тестирования JavaScript"
GeeksLab Odessa
 
PDF
Quick tour to front end unit testing using jasmine
Gil Fink
 
PDF
Automated Web Testing using JavaScript
Simon Guest
 
PDF
JavaScript Test-Driven Development with Jasmine 2.0 and Karma
Christopher Bartling
 
PPTX
TDD and the Legacy Code Black Hole
Noam Kfir
 
PDF
Testing in FrontEnd World by Nikita Galkin
Sigma Software
 
PDF
JAVASCRIPT TDD(Test driven Development) & Qunit Tutorial
Anup Singh
 
PPTX
Automated Testing using JavaScript
Simon Guest
 
PDF
A Introduction to the World of Node, Javascript & Selenium
James Eisenhauer
 
3 Ways to test your ColdFusion API - 2017 Adobe CF Summit
Ortus Solutions, Corp
 
3 WAYS TO TEST YOUR COLDFUSION API
Gavin Pickin
 
3 WAYS TO TEST YOUR COLDFUSION API -
Ortus Solutions, Corp
 
How do I Write Testable Javascript so I can Test my CF API on Server and Client
ColdFusionConference
 
How do I write Testable Javascript so I can Test my CF API on Server and Client
Gavin Pickin
 
Node.js Development Workflow Automation with Grunt.js
kiyanwang
 
Java script unit testing
Mats Bryntse
 
How to write Testable Javascript
ColdFusionConference
 
How do I write Testable Javascript - Presented at dev.Objective() June 16, 2016
Gavin Pickin
 
Testing nodejs apps
felipefsilva
 
JavaScript TDD with Jasmine and Karma
Christopher Bartling
 
JS Lab`16. Сергей Селецкий: "Ретроспектива тестирования JavaScript"
GeeksLab Odessa
 
Quick tour to front end unit testing using jasmine
Gil Fink
 
Automated Web Testing using JavaScript
Simon Guest
 
JavaScript Test-Driven Development with Jasmine 2.0 and Karma
Christopher Bartling
 
TDD and the Legacy Code Black Hole
Noam Kfir
 
Testing in FrontEnd World by Nikita Galkin
Sigma Software
 
JAVASCRIPT TDD(Test driven Development) & Qunit Tutorial
Anup Singh
 
Automated Testing using JavaScript
Simon Guest
 
A Introduction to the World of Node, Javascript & Selenium
James Eisenhauer
 
Ad

Recently uploaded (20)

PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
PDF
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
PDF
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
Staying Human in a Machine- Accelerated World
Catalin Jora
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
Biography of Daniel Podor.pdf
Daniel Podor
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PDF
Advancing WebDriver BiDi support in WebKit
Igalia
 
PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PDF
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
PDF
July Patch Tuesday
Ivanti
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
Staying Human in a Machine- Accelerated World
Catalin Jora
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
Biography of Daniel Podor.pdf
Daniel Podor
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
Advancing WebDriver BiDi support in WebKit
Igalia
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
July Patch Tuesday
Ivanti
 

Frontend automation and stability

  • 1. Frontend automation and stability @matenadasdi Ustream, Inc
  • 2. Common sentences from the past Writing tests is a huge overhead Browsers are unpredictable and we are not able to test real behaviour Let’s write this frontend task in PHP, Ruby, Python, Bash … Selenium is unstable and complicated “
  • 3. It’s a new ERA Let’s ride it!
  • 5. ! Trendy question: TDD is dead? </flame>
  • 7. Good news! We have everything what we need Hundreds of tools and frameworks - Mocha, Jasmine, Jest, Karma, QUnit Headless browsers - PhantomJS, SlimerJS, TrifleJS Headless navigation scripting libs - CasperJS, DalekJS
  • 10. Criterions for efficient unit testing Separated layers with different responsibilities for easier mocking Business Logic and the representation have to be separated Dependency Injection
  • 11. Mocha + Chai framework: Node and Browser support Separate assert libraries Tons of reporters mocking: SinonJS Spies, Stubs, Mocks Assertions for invocations Faking AJAX, server Works with lot of frameworks module dependency mocking: SquireJS Dependency injector for RequireJS mock / store
  • 12. It’s not an overhead, easy to run and write!
  • 13. Coverage? function coverage function epam (speaker, onStage) { var talking = false; ! if (speaker && onStage){ talking = true; } ! return talking; } if epam called once, its covered statement coverage function epam (speaker, onStage) { var talking = false; ! if (speaker && onStage){ talking = true; } ! return talking; } with testing epam(true, true), all statement will be executed, so its covered branch coverage function epam (speaker, onStage) { var talking = false; ! if (speaker && onStage){ talking = true; } ! return talking; } with testing epam(true, true), and epam (true, false) all execution paths will be covered
  • 14. Ok it’s nice, but is it possible in JS? ;)
  • 15. Istanbul https://github.com/gotwarlost/istanbul Esprima based statement, branch, function coverage multiple reporters command line support Karma test runner http://karma-runner.github.io/0.12/index.html + WebStorm integration Istanbul code coverage support Mocha, Jasmine, QUnit support Jenkins, Travis support
  • 16. Unit tests cannot cover everything! Browser / DOM / Interaction specific behaviour should be tested in a different way
  • 17. 2. UI testing The genie is out of the bottle
  • 19. We use CasperJS Node.js based navigation scripting PhantomJS & SlimerJS support screenshot capture not necessary to use its testing framework Pro: phantomjs based browsers only Cons:
  • 20. This is Node, you can do everything! Create your own modules you can call global casper from everywhere
  • 21. DalekJS is coming up! Real browser support Chrome, FF, IE, Mobile Safari It can run in headless browsers too Pro: strict testing framework interface small documentation and not enough methods still developer preview (0.0.8) Cons:
  • 22. 3. Test automation team selenium, real browsers, complex features, mobile devices
  • 23. 4. Manual QA team Smoke tests, regression tests, screenshot comparison tool, internal debug tools
  • 26. NPM for dependency management we could port every frontend related task to Node we use 12 grunt plugins (2800+ available globally) be careful, lot of tasks can lead to a huge/complex grunt file we have an own structure for task configurations Thanks to Grunt...
  • 27. Why not Gulp? a bad question
  • 28. Node streams are awesome, but it can be hard for non-js devs Code over configuration 713 plugins and coming up really fast Try both, and maybe use both! Gulp is good tool too!
  • 30. Our previous setup was too simple JSLint manually (!) YuiCompressor after commits in Jenkins
  • 31. Rules are not rules if you break them!
  • 32. Everyone writes different code and it’s normal
  • 33. Code style! Be aggressive! a smarter JSLint separated configuration file everyone can run the same config most IDEs can read it globally
  • 35. { "type": "Program", "body": [{ "type": "IfStatement", "test": { "type": "Identifier", "name": "epam" }, “consequent": { "type": "BlockStatement", "body": [{ "type": "ExpressionStatement", "expression": { "type": "AssignmentExpression", "operator": "=", "left": { "type": "Identifier", "name": "conf" }, "right": { "type": "Literal", "value": "SEC", "raw": "'SEC'" } } }] }, "alternate": null }] var epam = true; ! if (epam) { conf = 'SEC'; }
  • 36. Semantics & your own rules Esprima based pluginable thanks to the AST it can examine semantics
  • 37. Esprima based rule definitions
  • 39. Who wouldn’t wanna track these? http://jscomplexity.org/complexity Lines of code (LOC) Halstead complexity measures Maintainability index Cyclomatic complexity
  • 40. Cyclomatic complexity = E - N + 2P linearly independent paths in the method E = number of edges in the flow graph N = number of nodes in the flow graph P = number of nodes that have exit points 6 -6 + 2 = 2
  • 41. JSComplexity & Plato We run complexity report in Jenkins nightly build for our whole JS codebase https://www.npmjs.org/package/complexity-report Plato is a great tool for manual examinations https://github.com/es-analysis/plato
  • 43. CI Integration CI can run your tools automatically and periodically It can catch accidental commits Nearly every grunt plugin supports .xml reporters
  • 44. this 3 simple things can lead to a more stable and scalable JS codebase Testing Automation Standards & rules !