SlideShare une entreprise Scribd logo
1  sur  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?

Contenu connexe

Tendances

Tendances (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
 

En vedette

En vedette (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
 

Similaire à 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
 

Similaire à 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
 

Plus de Robert Greiner

Plus 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
 

Dernier

+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@
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Dernier (20)

Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
+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...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
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
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
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...
 
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
 
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
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
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
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 

Testing javascript