SlideShare una empresa de Scribd logo
1 de 38
Testing JavaScript

    with Jasmine
Why should we test JavaScript?
How many times have you
changed something in JavaScript
Only to break something else?
JavaScript = Production Code!
Which means, we need to treat it
        with respect
And, preserve the ability to
change
fix
clean
and refactor our JavaScript code
Without fear of breaking
      something
Testing is especially important when
 external factors can affect how our
            code functions
What makes a good test?
Think F.I.R.S.T
Fast
Independent

Tests should not depend on each
              other.
Repeatable

Always the same results, regardless
         of environment.
Self-Validating

     Pass or Fail
No manual evalutation.
Timely

Write tests before production code.
Let’s look at an example.

A random function for rolling a die.
What’s wrong here?
How do we normally debug
       JavaScript?
Let’s forget we even mentioned
              that…
So… we have this buggy code.
What do we do about it?
Write a failing test
Then Run the test to see it fail
SpecRunner.html
Squash the bug
Success!
Add more tests
Win!




Testing = Documentation!
Remember…
When you find yourself wanting
         to do this.
Write a test instead!
Questions?

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

DevoxxUK: Learning programming through osmosis
DevoxxUK: Learning programming through osmosisDevoxxUK: Learning programming through osmosis
DevoxxUK: Learning programming through osmosis
 
Breakpoint 2021: Contemporary exploratorytesting
Breakpoint 2021: Contemporary exploratorytestingBreakpoint 2021: Contemporary exploratorytesting
Breakpoint 2021: Contemporary exploratorytesting
 
Tasting Your First Test Burger
Tasting Your First Test BurgerTasting Your First Test Burger
Tasting Your First Test Burger
 
HUSTEF '21 Keynote: Hands Off Exploratory Testing - Managing at Scale
HUSTEF '21 Keynote: Hands Off Exploratory Testing - Managing at ScaleHUSTEF '21 Keynote: Hands Off Exploratory Testing - Managing at Scale
HUSTEF '21 Keynote: Hands Off Exploratory Testing - Managing at Scale
 
Programming Assignments in Tester Interviews
Programming Assignments in Tester InterviewsProgramming Assignments in Tester Interviews
Programming Assignments in Tester Interviews
 
SLASSCOM: Breaking illusions with Testing
SLASSCOM: Breaking illusions with TestingSLASSCOM: Breaking illusions with Testing
SLASSCOM: Breaking illusions with Testing
 
Talentum: Testiautomaation tekemisen taito
Talentum: Testiautomaation tekemisen taitoTalentum: Testiautomaation tekemisen taito
Talentum: Testiautomaation tekemisen taito
 
Hands off Exploratory Testing - Managing Testing at Scale
Hands off Exploratory Testing - Managing Testing at ScaleHands off Exploratory Testing - Managing Testing at Scale
Hands off Exploratory Testing - Managing Testing at Scale
 
ATAGTR Keynote: I have a rock in my shoe - Navigating Improvement
ATAGTR Keynote: I have a rock in my shoe - Navigating ImprovementATAGTR Keynote: I have a rock in my shoe - Navigating Improvement
ATAGTR Keynote: I have a rock in my shoe - Navigating Improvement
 
Selenium Summit 21: Contemporary Exploratory Testing
Selenium Summit 21: Contemporary Exploratory TestingSelenium Summit 21: Contemporary Exploratory Testing
Selenium Summit 21: Contemporary Exploratory Testing
 
DDD Europe: Breaking Illusions with Testing (keynote)
DDD Europe: Breaking Illusions with Testing (keynote)DDD Europe: Breaking Illusions with Testing (keynote)
DDD Europe: Breaking Illusions with Testing (keynote)
 
AADays Poland: Perfecting the Craft of Test Automation
AADays Poland: Perfecting the Craft of Test AutomationAADays Poland: Perfecting the Craft of Test Automation
AADays Poland: Perfecting the Craft of Test Automation
 
Agile2016: (Lightning Talk) Breaking illusions
Agile2016: (Lightning Talk) Breaking illusionsAgile2016: (Lightning Talk) Breaking illusions
Agile2016: (Lightning Talk) Breaking illusions
 
Building test scripts
Building test scriptsBuilding test scripts
Building test scripts
 
TMAcad: We're work in Progress, Lessons on Becoming a Great Tester
TMAcad: We're work in Progress, Lessons on Becoming a Great TesterTMAcad: We're work in Progress, Lessons on Becoming a Great Tester
TMAcad: We're work in Progress, Lessons on Becoming a Great Tester
 
Check methods params_for_validity
Check methods params_for_validityCheck methods params_for_validity
Check methods params_for_validity
 
Testing Without Waste - Automatic Testing
Testing Without Waste - Automatic TestingTesting Without Waste - Automatic Testing
Testing Without Waste - Automatic Testing
 
13 javascript techniques to improve your code
13 javascript techniques to improve your code13 javascript techniques to improve your code
13 javascript techniques to improve your code
 
Agile2016: Exploratory Testing an API
Agile2016: Exploratory Testing an APIAgile2016: Exploratory Testing an API
Agile2016: Exploratory Testing an API
 
Mob testing
Mob testingMob testing
Mob testing
 

Destacado

Destacado (6)

Petabytes and Nanoseconds
Petabytes and NanosecondsPetabytes and Nanoseconds
Petabytes and Nanoseconds
 
Code Quality and Tipster
Code Quality and TipsterCode Quality and Tipster
Code Quality and Tipster
 
Test Driven Development at 10,000 Feet
Test Driven Development at 10,000 FeetTest Driven Development at 10,000 Feet
Test Driven Development at 10,000 Feet
 
Automated Testing for Websites With Selenium IDE
Automated Testing for Websites With Selenium IDEAutomated Testing for Websites With Selenium IDE
Automated Testing for Websites With Selenium IDE
 
Fin fest 2014 - Internet of Things and APIs
Fin fest 2014 - Internet of Things and APIsFin fest 2014 - Internet of Things and APIs
Fin fest 2014 - Internet of Things and APIs
 
Introduction to Amazon Web Services
Introduction to Amazon Web ServicesIntroduction to Amazon Web Services
Introduction to Amazon Web Services
 

Similar a Testing javascript

I Smell A RAT- Rapid Application Testing
I Smell A RAT- Rapid Application TestingI Smell A RAT- Rapid Application Testing
I Smell A RAT- Rapid Application Testing
Peter Presnell
 
Test automation expert days
Test automation   expert daysTest automation   expert days
Test automation expert days
Oren Rubin
 

Similar a Testing javascript (20)

I Smell A RAT- Rapid Application Testing
I Smell A RAT- Rapid Application TestingI Smell A RAT- Rapid Application Testing
I Smell A RAT- Rapid Application Testing
 
Tdd - introduction
Tdd - introductionTdd - introduction
Tdd - introduction
 
Let's test!
Let's test!Let's test!
Let's test!
 
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | Fal...
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | Fal...Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | Fal...
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | Fal...
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Testing recipes
Testing recipesTesting recipes
Testing recipes
 
Test Driven Development with Laravel
Test Driven Development with LaravelTest Driven Development with Laravel
Test Driven Development with Laravel
 
Test automation expert days
Test automation   expert daysTest automation   expert days
Test automation expert days
 
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
assertYourself - Breaking the Theories and Assumptions of Unit Testing in FlexassertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
 
Unit testing
Unit testingUnit testing
Unit testing
 
Agile JavaScript Testing
Agile JavaScript TestingAgile JavaScript Testing
Agile JavaScript Testing
 
Automated tests
Automated testsAutomated tests
Automated tests
 
Software Testing Basic Concepts
Software Testing Basic ConceptsSoftware Testing Basic Concepts
Software Testing Basic Concepts
 
JavaScript Unit Testing
JavaScript Unit TestingJavaScript Unit Testing
JavaScript Unit Testing
 
Real Life Unit Testing
Real Life Unit TestingReal Life Unit Testing
Real Life Unit Testing
 
Js unit testing
Js unit testingJs unit testing
Js unit testing
 
Unit Test Lab - Why Write Unit Tests?
Unit Test Lab - Why Write Unit Tests?Unit Test Lab - Why Write Unit Tests?
Unit Test Lab - Why Write Unit Tests?
 
Unit tests & TDD
Unit tests & TDDUnit tests & TDD
Unit tests & TDD
 
Why Unit Testingl
Why Unit TestinglWhy Unit Testingl
Why Unit Testingl
 
Why unit testingl
Why unit testinglWhy unit testingl
Why unit testingl
 

Más de Robert Greiner

Más de Robert Greiner (9)

Portfolio Rationalization - Making Sound Financial and Strategic Decisions in...
Portfolio Rationalization - Making Sound Financial and Strategic Decisions in...Portfolio Rationalization - Making Sound Financial and Strategic Decisions in...
Portfolio Rationalization - Making Sound Financial and Strategic Decisions in...
 
Virtual Team Best Practices
Virtual Team Best PracticesVirtual Team Best Practices
Virtual Team Best Practices
 
Becoming the Ideal Team Player
Becoming the Ideal Team PlayerBecoming the Ideal Team Player
Becoming the Ideal Team Player
 
POV - Practical Containerization
POV - Practical ContainerizationPOV - Practical Containerization
POV - Practical Containerization
 
POV - Enterprise Security Canvas
POV - Enterprise Security CanvasPOV - Enterprise Security Canvas
POV - Enterprise Security Canvas
 
Foundations of financial independence
Foundations of financial independenceFoundations of financial independence
Foundations of financial independence
 
Why feedback is important
Why feedback is importantWhy feedback is important
Why feedback is important
 
Infrastructure as Code
Infrastructure as CodeInfrastructure as Code
Infrastructure as Code
 
Introduction to Windows Azure Data Services
Introduction to Windows Azure Data ServicesIntroduction to Windows Azure Data Services
Introduction to Windows Azure Data Services
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
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
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Último (20)

Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
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
 
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, ...
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
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
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
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
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
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
 

Testing javascript