SlideShare a Scribd company logo
JS Unit Testing
Team: El Pimpi
Mihail Gaberov
Motivation
● To have all team members acknowledged in the field and
be able to write unit test for our Javascript based
projects.
● This could be continued as series of internal workshops
in order to keep improving ourselves in all front end
skills that we need or might need.
What is a JS Unit test?
● A pure function that you can deal with — a function that
always gives you the same result for a given input. This
makes unit testing pretty easy, but most of the time you
need to deal with side effects (DOM manipulations, API calls,
etc). It’s still useful to figure out which units we can
structure our code into and to build unit tests accordingly.
● 5 Questions Every Unit Test Must Answer
● Example:

it(‘Description of the test’, () => {

// Implementation of the test

expect(true).to.be(true)

})
Why do we need to write unit tests?
● Make us to refactor the code, in order to make it
testable. This means to make it scalable and
modularised and easy to reason about it. Helps
automation and avoiding manual testing.
● Slow us in the beginning, speed up after.
● A must for almost every project - no tests only for very,
really very small ones.
● Help us reasoning about the quality of our code.
● Change the way of thinking when programming.
How do we write JS unit tests?
● Testing libraries - mocha, jasmine
● Assertion libraries - chai, expect.js, should.js
● Async testing - sinonjs (next time more on this)
Examples
https://github.com/mihailgaberov/javascript-testing
References:
● http://howtodoinjava.com/scripting/javascript/
jasmine-javascript-unit-testing-tutorial/
● https://classroom.udacity.com/courses/ud549/lessons/
3769099021/concepts/38687287730923
● https://www.smashingmagazine.com/2012/06/
introduction-to-javascript-unit-testing/
● https://www.sitepoint.com/javascript-testing-tool-
showdown-sinon-js-vs-testdouble-js

More Related Content

PPTX
PPTX
xUnit test patterns 0
PDF
EVOLVE'15 | Enhance | Rene Ugarte | AEM Quality Assurance
PPT
VodQA3_ATDD_KetanSoni
PPTX
Tdd and bdd
PPTX
Automation and Technical Debt
ODP
Illia Seleznov - Integration tests for Spring Boot application
PPTX
ATDD with Pepino
xUnit test patterns 0
EVOLVE'15 | Enhance | Rene Ugarte | AEM Quality Assurance
VodQA3_ATDD_KetanSoni
Tdd and bdd
Automation and Technical Debt
Illia Seleznov - Integration tests for Spring Boot application
ATDD with Pepino

What's hot (20)

PPTX
Testing JavaScript Applications
PDF
What is Agile Testing?
PDF
Test Driven Development
PPTX
Unit Testing in Action - C#, NUnit, and Moq
PPT
Speed up your tests
PPTX
JavaScript Unit Testing
PDF
Feature toggling
PPTX
Codeception @ New Business Dept Adira Finance
PPTX
Feature toggles
PPTX
AspectMock
PPT
Test-Driven Development
PPT
Test-Driven Development
PPT
Test Driven Development
PDF
Test Driven Development Powered by LEGO
PDF
Tdd red-green-refactor
PPTX
What Is Cucumber?
PPTX
Feature Toggles
PPTX
Behavioral tests with behat for qa
PDF
Tdd 왜 배우기 어려운가
Testing JavaScript Applications
What is Agile Testing?
Test Driven Development
Unit Testing in Action - C#, NUnit, and Moq
Speed up your tests
JavaScript Unit Testing
Feature toggling
Codeception @ New Business Dept Adira Finance
Feature toggles
AspectMock
Test-Driven Development
Test-Driven Development
Test Driven Development
Test Driven Development Powered by LEGO
Tdd red-green-refactor
What Is Cucumber?
Feature Toggles
Behavioral tests with behat for qa
Tdd 왜 배우기 어려운가
Ad

Similar to JavaScript Unit Testing (20)

PDF
Getting started with karate dsl
PDF
Wso2con test-automation
PDF
Unit Testing in Angular
PPTX
Unit Testing and TDD 2017
PPTX
Test driven development
PDF
Writing Tests with the Unity Test Framework
PPTX
Test-Driven Development In Action
PDF
WSO2Con Asia 2014 - Effective Test Automation in an Agile Environment
PPTX
Test Driven Development
PDF
Testing Django Applications
PPTX
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
PDF
Unit testing (eng)
PDF
Testing Experience - Evolution of Test Automation Frameworks
PDF
Testacular
PDF
Should you be your own judge?
PDF
TDD Workshop UTN 2012
ODP
Testing & continuous delivery
PDF
Unit testing
PPTX
Test driven development in .Net - 2010 + Eclipse
PPT
Unit testing
Getting started with karate dsl
Wso2con test-automation
Unit Testing in Angular
Unit Testing and TDD 2017
Test driven development
Writing Tests with the Unity Test Framework
Test-Driven Development In Action
WSO2Con Asia 2014 - Effective Test Automation in an Agile Environment
Test Driven Development
Testing Django Applications
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
Unit testing (eng)
Testing Experience - Evolution of Test Automation Frameworks
Testacular
Should you be your own judge?
TDD Workshop UTN 2012
Testing & continuous delivery
Unit testing
Test driven development in .Net - 2010 + Eclipse
Unit testing
Ad

Recently uploaded (20)

PPTX
Essential Infomation Tech presentation.pptx
PDF
top salesforce developer skills in 2025.pdf
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
PTS Company Brochure 2025 (1).pdf.......
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
AI in Product Development-omnex systems
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PPTX
Reimagine Home Health with the Power of Agentic AI​
PPTX
Odoo POS Development Services by CandidRoot Solutions
Essential Infomation Tech presentation.pptx
top salesforce developer skills in 2025.pdf
VVF-Customer-Presentation2025-Ver1.9.pptx
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PTS Company Brochure 2025 (1).pdf.......
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Wondershare Filmora 15 Crack With Activation Key [2025
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
How to Migrate SBCGlobal Email to Yahoo Easily
AI in Product Development-omnex systems
How to Choose the Right IT Partner for Your Business in Malaysia
Operating system designcfffgfgggggggvggggggggg
Which alternative to Crystal Reports is best for small or large businesses.pdf
Design an Analysis of Algorithms I-SECS-1021-03
Reimagine Home Health with the Power of Agentic AI​
Odoo POS Development Services by CandidRoot Solutions

JavaScript Unit Testing

  • 1. JS Unit Testing Team: El Pimpi Mihail Gaberov
  • 2. Motivation ● To have all team members acknowledged in the field and be able to write unit test for our Javascript based projects. ● This could be continued as series of internal workshops in order to keep improving ourselves in all front end skills that we need or might need.
  • 3. What is a JS Unit test? ● A pure function that you can deal with — a function that always gives you the same result for a given input. This makes unit testing pretty easy, but most of the time you need to deal with side effects (DOM manipulations, API calls, etc). It’s still useful to figure out which units we can structure our code into and to build unit tests accordingly. ● 5 Questions Every Unit Test Must Answer ● Example:
 it(‘Description of the test’, () => {
 // Implementation of the test
 expect(true).to.be(true)
 })
  • 4. Why do we need to write unit tests? ● Make us to refactor the code, in order to make it testable. This means to make it scalable and modularised and easy to reason about it. Helps automation and avoiding manual testing. ● Slow us in the beginning, speed up after. ● A must for almost every project - no tests only for very, really very small ones. ● Help us reasoning about the quality of our code. ● Change the way of thinking when programming.
  • 5. How do we write JS unit tests? ● Testing libraries - mocha, jasmine ● Assertion libraries - chai, expect.js, should.js ● Async testing - sinonjs (next time more on this)
  • 7. References: ● http://howtodoinjava.com/scripting/javascript/ jasmine-javascript-unit-testing-tutorial/ ● https://classroom.udacity.com/courses/ud549/lessons/ 3769099021/concepts/38687287730923 ● https://www.smashingmagazine.com/2012/06/ introduction-to-javascript-unit-testing/ ● https://www.sitepoint.com/javascript-testing-tool- showdown-sinon-js-vs-testdouble-js