Testing JavaScript Applications What? Why? How?
Hello! Auwal Muhammad Samu Software Engineer,@intapps Community Manager, GDG Lafia Tweets: @auwalms_ Other Socials: @auwalms Mails: auwalforall@gmail.com
What is a Test?1
“ Testing is the process of evaluating a system or its component(s) with the intent to find whether it satisfies the specified requirements or not.
“ A process of analyzing a software item to detect the differences between existing and required conditions (that is defects/errors/bugs) and to evaluate the features of the software item. - ANSI/IEEE 1059 standard
Why write a Test?2
Write Test so as to: ◉spend less debugging time and save cost ◉ship less buggy codes ◉ensure user requirement are met ◉identify errors and gaps
What do you Test?3
Writing Tests depends on: ◉what the test is expected to achieve ◉the level and depth of the test expectation ◉Non-Functional Testing ◉Functional Testing
Image Source: http://testwithbest.blogspot.com.ng/p/ manual-testing.html
Image Source: http://www.mamsys.com/quality- assurance/functional-testing/
Functional Testing4
Ensure tests are written for: ◉Areas where large users will be accessing simultaneously such ◉Login/registration form ◉Bill/payment pages ◉Connection to DB ◉Expected response from database ◉Components interaction with each others
Unit Test The main aim is to isolate each part of a program and show that the section of code works correctly.
Integration Test Involves testing of combined parts of a program to ensure its working based on user requirement.
System Test Is performed when all components of a program are integrated and tested to ensure functionality.
Writing Test in JS5
JavaScript does not natively supports testing It employs the good will of some of its frameworks and library to achieve this fit for testing in both Node and browsers
Some JS Testing Frameworks ◉Mocha ◉Jasmine ◉Jest ◉Selenium ◉QUnit ◉Tape ◉Protractor
Some JS Testing Library ◉Chai ◉Sinon ◉Enzyme ◉Unexpected ◉WebdriverIO ◉ and many others
Using Mocha for Testing 5
Why Mocha? ◉ a feature-rich JS testing framework that runs on node and browser ◉ most used testing framework for testing ◉ support usage of 3rd party library for assertion, mocks, spy and others
Adding Mocha to Project //Mocha can be installed with npm, bower and available on cdnjs //install globally with npm using npm install -g mocha //install as a dev dependency for your project npm install --save-dev mocha //installed using bower as bower install mocha
And then structure?
<demo-time/>
Akwai tambaya ? You can find me at ◉ @auwalms_ ◉ auwalforall@gmail.com Nagode!

Testing JavaScript Applications

Editor's Notes