Slide 1

Slide 1 text

Testing JavaScript By Irfan Maulana

Slide 2

Slide 2 text

Hi, I am Irfan Working at Tokopedia as Principal Engineer for Web Platform Team. mazipan.space @Maz_Ipan

Slide 3

Slide 3 text

A process to verifying the correctness & validating the functional features of the app being developed APPLICATION TESTING

Slide 4

Slide 4 text

Software Development Life Cycle

Slide 5

Slide 5 text

JAVASCRIPT APPLICATION Frontend Backend Handling UI functionality: web, apps, desktop Handling business logic, data store connection A B We will focus on the Frontend for this session.

Slide 6

Slide 6 text

PERFORM APP TESTING MANUAL AUTOMATED

Slide 7

Slide 7 text

WHY DO WE NEED? Bugs are bad, and who gets blamed? The developer. You know humans are bad at complex, repetitive tasks. Computers are very, very good at complex, repetitive tasks. A professional ships working code. Code that works. Code that is well tested.

Slide 8

Slide 8 text

Focused on input & output. Not interested about the things happening inside. Involve testing of the internal structure, code, design & implementation. METHODOLOGIES BLACKBOX WHITEBOX

Slide 9

Slide 9 text

TESTING PROCESS 1. PLANNING 2. PREPARATION 3. EXECUTION 4. REPORTING

Slide 10

Slide 10 text

THE TESTING TYPES

Slide 11

Slide 11 text

PROVEN METHOD FOR TESTING APP

Slide 12

Slide 12 text

STATIC TEST To catch typos, errors, possible bugs as you write the code. Tools: ● ESLint + Prettier ● CodeQL, Snyk, SonarQube

Slide 13

Slide 13 text

Very fast feedback Can not reproduce functional bugs faced by users STATIC TEST: PRO & CONS We can mark it as mandatory Very beneficial in the development phase

Slide 14

Slide 14 text

UNIT TEST To verify that individual, isolated and smallest part works as expected. Tools: ● TestingLibrary.com

Slide 15

Slide 15 text

Fast feedback Need an extra effort to write UT UNIT TEST: PRO & CONS Verify the correctness of the function Can not represent the bug when the unit integrated Can not represent real user interaction

Slide 16

Slide 16 text

INTEGRATION TEST To verify that several units work together in harmony. Tools: ● TestingLibrary.com

Slide 17

Slide 17 text

Verify most of user interactions Slower feedback than UT More effort than UT INTEGRATION TEST: PRO & CONS Can not represent device variant Can not replicate using the real data

Slide 18

Slide 18 text

END-TO-END TEST A robot that behaves like a user to click around the app and verify that it functions correctly. Tools: ● Cypress ● Nightwatch ● TestCafe

Slide 19

Slide 19 text

Can use multiple device Very slow to executed Need the biggest effort E2E TEST: PRO & CONS Can use real data Replicate real user

Slide 20

Slide 20 text

COMPARISON Static Test Unit Test Integration E2E Test 🚀 Speed 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 ⏰ Development time 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 💰 Cost 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 😎 Confidence 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 Read more on https://kentcdodds.com/blog/static-vs-unit-vs-integration-vs-e2e-tests

Slide 21

Slide 21 text

BEST ROI https://twitter.com/kentcdodds/status/960723172591992832

Slide 22

Slide 22 text

DEMO TIME!

Slide 23

Slide 23 text

CHECK THE CODE https://github.com/mazipan/react-testing-workshop Prerequisites: ● Node.js

Slide 24

Slide 24 text

ASK ME!

Slide 25

Slide 25 text

CREDITS: This presentation template was created by Slidesgo, including icons by Flaticon, and infographics & images by Freepik and illustrations by Stories. THANK YOU Please keep this slide for attribution.