SlideShare a Scribd company logo
HOW TO KEEP HIGH CODE
QUALITY WITHOUT E2E TESTS
„Vladyslav Romanchenko,
„Senior QA Automation/UI
Developer @Luxoft
„5+ years experience in Test
Automation and
Development
WHO AM I?
WHAT DO WE TEST?
REQUIREMENTS
„Fast, reliable UI tests
„Test should be used during development
„Tests should run and pass even if BE is down
„Tests should not require much maintenance
THE PROBLEMS WE HAD WITH E2E
„No Predictable Data
„Human review of Events
„UI tests are unstable
„Some daemons are running once in 2 minutes
SOLUTION
„Use Unit and Integration tests
THE RESULTS WE GOT
„Tests are finished in 73 seconds
„Tests are finding errors
„Tests help develop faster
MAIN FUNCTIONS OF UI
1. Send correct requests to BE
2. Calculate or prepare data using helper
functions or Redux
3. Correctly render information from BE
4. Respond to user interaction through Event
Listeners
TECHNOLOGIES USED
„React
„Redux
„Enzyme/React testing library
„Jest
TECHNOLOGY BASICS
What is React?
TECHNOLOGY BASICS
React allows to create small reusable
components that contain all the needed HTML,
CSS and JavaScript code (JSX)
TECHNOLOGY BASICS
TECHNOLOGY BASICS
Redux – Predictable state container for
JavaScript apps
TECHNOLOGY BASICS
Important to know about Redux:
„Manages global state for all the application
„Uses pure functions
„State is always immutable
„New state is created using Actions
TECHNOLOGY BASICS
TECHNOLOGY BASICS
Action is a simple JS object that has type field:
TECHNOLOGY BASICS
Reducer is a function that takes state and action
and returns new state:
TECHNOLOGY BASICS
Selector is a function that takes state and returns
only parts that are needed. Use ’reselect’ to
memoize selectors:
WHAT TO TEST
„Helper Functions
„Action Creators
„Reducer
„Selectors
„Components rendering
„Component event handlers
„Component helper functions (class methods)
HOW TO TEST
HELPER FUNCTIONS
ASIDE
There are 3 types of functions:
ØPure functions
ØImpure functions
ØClosures
ASIDE
Pure functions always return the same result for
the same arguments.
ASIDE
Result of Impure functions depends on some
other variable, state or function changes
arguments that are passed to it
ASIDE
Closures return function as a result
ASIDE
Pure function
ASIDE
Impure function
ASIDE
Impure function that uses state
ASIDE
Closure
ASIDE
Closure/Thunk
HOW TO TEST
HOW TO TEST
Pure function
HOW TO TEST
Mock everything to test Impure functions
HOW TO TEST
Call functions immediately to test closures
HOW TO TEST
ACTION CREATORS/THUNKS
ASIDE
Thunk allows to dispatch functions instead of an
actions.
It is used to send requests to BE and create side
effects.
ASIDE
Thunk example
HOW TO TEST
Simple Action Creator testing steps:
„Mock Store
„Dispatch Action
„Check what Actions were emitted
HOW TO TEST
Mock Store
HOW TO TEST
Run test
HOW TO TEST
Async Action Creators testing steps:
„Mock Store
„Mock Fetch/Async action
„Dispatch Action
„Check what Actions were emitted
„Check how fetch was called
HOW TO TEST
Use async to make your tests asynchronous in
order to test requests that are being sent
HOW TO TEST
Use await to check the result
HOW TO TEST
Mock fetch to check requests
You can do it in config
HOW TO TEST
If you are using TypeScript you would need to use
FetchMock interface
HOW TO TEST
Now you are ready to mock API responses
HOW TO TEST
Don’t forget to run some negative tests
HOW TO TEST
Time to check the results
HOW TO TEST
Don’t forget await, when checking
HOW TO TEST
What to do if there is an error thrown?
HOW TO TEST
Use try/catch when you expect error
HOW TO TEST
Modify state to check functions that use data
from state
HOW TO TEST
Use spys to mock functions
HOW TO TEST
REDUCER
HOW TO TEST
Steps to test Reducer
„Mock all the needed parts of state
„Prepare resulting state for each action
„Call reducer with mocked state
„Check the result
HOW TO TEST
Here is an example
HOW TO TEST
Change state directly in expect for simple cases
HOW TO TEST
SELECTORS
HOW TO TEST
Steps to test selectors
„Mock State or use resultFunc
„Check the output from selector
HOW TO TEST
Pass prepared state to selector
HOW TO TEST
Prepare expectedResult
HOW TO TEST
Call selector with prepared state
HOW TO TEST
Use resultFunc if selector takes other selectors as
inputs
HOW TO TEST
Use resultFunc if selector takes other selectors as
inputs
HOW TO TEST
COMPONENTS RENDERING
HOW TO TEST
Steps to test Component
„Use render to render component
„Use getByTestId or getByText to locate elements
„ Use fireEvent to interact with elements
HOW TO TEST
Rendering
HOW TO TEST
Fire event to check interaction
HOW TO TEST
Mock functions to check its parameters
WHAT TO DO NEXT
Next steps
„Refactor class methods to separate files
„Implement Visual regression in different
browsers
BONUS
BONUS
Use debugger and copy(variableName) to
prepare data for tests
BONUS
Insert debugger
BONUS
Once you reach debugger, an app is going to
pause
BONUS
Open console and run `copy` command with
variable name as parameter
Q & A

More Related Content

PPTX
Refactoring
PDF
Functional Testing
PPTX
An introduction to api testing | David Tzemach
PPTX
Angular Unit Test
PDF
API Testing: Answers to Your Top 3 Questions
PPTX
Unit & integration testing
PDF
Angular Unit Testing from the Trenches
PDF
Angular Unit Testing NDC Minn 2018
Refactoring
Functional Testing
An introduction to api testing | David Tzemach
Angular Unit Test
API Testing: Answers to Your Top 3 Questions
Unit & integration testing
Angular Unit Testing from the Trenches
Angular Unit Testing NDC Minn 2018

What's hot (20)

ODP
Rails Testing
PDF
Client side unit tests - using jasmine & karma
PPTX
Test api
PDF
Ddc2011 효과적으로레거시코드다루기
PPTX
Api testing
PPTX
RIA 05 - Unit Testing by Ajinkya Prabhune
PPTX
The complete guide for software integration testing | David Tzemach
PPTX
Angular Unit Testing
PDF
Unit Testing in WordPress
PDF
vREST for a new user
PDF
How to Automate API Testing
PPTX
Resilience and chaos engineering
PDF
Unit testing in Force.com platform
PPTX
An easy way to automate complex UI
PDF
mocha sinon chai Dc jquery 4-24
PPTX
Unit testing and mocking in Python - PyCon 2018 - Kenya
PPTX
Twelve Factor - Designing for Change
PPT
Functional Testing Swing Applications with Frankenstein
PDF
EasyTest Test Automation Tool Introduction
PDF
Eclipse Tips & Tricks - EclipseCon North America 2014
Rails Testing
Client side unit tests - using jasmine & karma
Test api
Ddc2011 효과적으로레거시코드다루기
Api testing
RIA 05 - Unit Testing by Ajinkya Prabhune
The complete guide for software integration testing | David Tzemach
Angular Unit Testing
Unit Testing in WordPress
vREST for a new user
How to Automate API Testing
Resilience and chaos engineering
Unit testing in Force.com platform
An easy way to automate complex UI
mocha sinon chai Dc jquery 4-24
Unit testing and mocking in Python - PyCon 2018 - Kenya
Twelve Factor - Designing for Change
Functional Testing Swing Applications with Frankenstein
EasyTest Test Automation Tool Introduction
Eclipse Tips & Tricks - EclipseCon North America 2014
Ad

Similar to Vladyslav Romanchenko "How to keep high code quality without e2e tests" (20)

ODP
Writing useful automated tests for the single page applications you build
PDF
Don't let your tests slow you down
PDF
ES3-2020-06 Test Driven Development (TDD)
PDF
How to push a react js application in production and sleep better
PDF
Best Practices for React Developer Test Technical Assessment for Hiring.pdf
PDF
UI Testing
PPTX
MidwestJS Zero to Testing
PPTX
Automation testing
PDF
An Introduction to the World of Testing for Front-End Developers
PDF
FITC Web Unleashed 2017 - Introduction to the World of Testing for Front-End ...
PDF
The Many Ways to Test Your React App
PDF
Workshop 23: ReactJS, React & Redux testing
PDF
Testing in FrontEnd World by Nikita Galkin
PDF
JAVASCRIPT Test Driven Development & Jasmine
PDF
Agile Software Testing the Agilogy Way
PDF
Intro To JavaScript Unit Testing - Ran Mizrahi
PDF
Test driven development and react js application go hand in hand
PDF
React a11y-csun
PDF
Collaborating with Developers: How-to Guide for Test Engineers - By Gil Tayar
PPTX
Java script unit testing
Writing useful automated tests for the single page applications you build
Don't let your tests slow you down
ES3-2020-06 Test Driven Development (TDD)
How to push a react js application in production and sleep better
Best Practices for React Developer Test Technical Assessment for Hiring.pdf
UI Testing
MidwestJS Zero to Testing
Automation testing
An Introduction to the World of Testing for Front-End Developers
FITC Web Unleashed 2017 - Introduction to the World of Testing for Front-End ...
The Many Ways to Test Your React App
Workshop 23: ReactJS, React & Redux testing
Testing in FrontEnd World by Nikita Galkin
JAVASCRIPT Test Driven Development & Jasmine
Agile Software Testing the Agilogy Way
Intro To JavaScript Unit Testing - Ran Mizrahi
Test driven development and react js application go hand in hand
React a11y-csun
Collaborating with Developers: How-to Guide for Test Engineers - By Gil Tayar
Java script unit testing
Ad

More from Dakiry (20)

PDF
НАРЦИСИЗМ ЯК ПАСИВНЕ КУРІННЯ
PDF
МАНІПУЛЯЦІЇ: ХТО КОГО І ДЛЯ ЧОГО? - Інна Тіторенко
PPTX
How to run a discovery workshop
PPTX
З понеділка йду на новий проект. The tester’s version - Олександра Зубаль
PDF
Робота з текстом: від чернетки до опублікування
PPTX
Контентна стратегія в ІТ: від статті до першого ліда
PPTX
Oleh Shpyrna "Security Testing Basics: Check your Webapp for gaps before l_unch"
PPTX
Stepan Shykerynets "Power of QA (A Journey: From Hell to Heaven. Story of gr...
PDF
Микола Солопій "Selenium рулить, однак..."
PDF
Oleksandra Zubal "Project starters: test automation view"
PPTX
Діана Пінчук "Як відрізнити авторизацію від аутентифікації та перестати бояти...
PPT
Yuriy Malyi "E2E testing organization in multi-system projects"
PPTX
Petro Tarasenko "You've become a TL. What's next?"
PDF
Roman Yakymchuk "Дослідницьке тестування. Перезапуск"
PPTX
Maryna Shulga "Mission Impossible. Впровадити тест процеси, якщо ніхто цього ...
PDF
Олексій Брошков "Мистецтво Дослідницького Тестування"
PPSX
Альона Тудан " Життя QA в ажурі"
PPTX
Андрій Степура "Тренди в публічних виступах"
PPTX
Зоряна Борбулевич "Підхід, який трансформував компанію Microsoft: ННК і його...
PPTX
Анатолій Лой Lessons Learned для БА по проекту "День турбот"
НАРЦИСИЗМ ЯК ПАСИВНЕ КУРІННЯ
МАНІПУЛЯЦІЇ: ХТО КОГО І ДЛЯ ЧОГО? - Інна Тіторенко
How to run a discovery workshop
З понеділка йду на новий проект. The tester’s version - Олександра Зубаль
Робота з текстом: від чернетки до опублікування
Контентна стратегія в ІТ: від статті до першого ліда
Oleh Shpyrna "Security Testing Basics: Check your Webapp for gaps before l_unch"
Stepan Shykerynets "Power of QA (A Journey: From Hell to Heaven. Story of gr...
Микола Солопій "Selenium рулить, однак..."
Oleksandra Zubal "Project starters: test automation view"
Діана Пінчук "Як відрізнити авторизацію від аутентифікації та перестати бояти...
Yuriy Malyi "E2E testing organization in multi-system projects"
Petro Tarasenko "You've become a TL. What's next?"
Roman Yakymchuk "Дослідницьке тестування. Перезапуск"
Maryna Shulga "Mission Impossible. Впровадити тест процеси, якщо ніхто цього ...
Олексій Брошков "Мистецтво Дослідницького Тестування"
Альона Тудан " Життя QA в ажурі"
Андрій Степура "Тренди в публічних виступах"
Зоряна Борбулевич "Підхід, який трансформував компанію Microsoft: ННК і його...
Анатолій Лой Lessons Learned для БА по проекту "День турбот"

Recently uploaded (20)

PDF
Dr. Enrique Segura Ense Group - A Self-Made Entrepreneur And Executive
PDF
Laughter Yoga Basic Learning Workshop Manual
DOCX
Euro SEO Services 1st 3 General Updates.docx
PDF
Ôn tập tiếng anh trong kinh doanh nâng cao
PPTX
job Avenue by vinith.pptxvnbvnvnvbnvbnbmnbmbh
PDF
Traveri Digital Marketing Seminar 2025 by Corey and Jessica Perlman
PPTX
ICG2025_ICG 6th steering committee 30-8-24.pptx
PDF
DOC-20250806-WA0002._20250806_112011_0000.pdf
PDF
kom-180-proposal-for-a-directive-amending-directive-2014-45-eu-and-directive-...
PDF
Business model innovation report 2022.pdf
PDF
BsN 7th Sem Course GridNNNNNNNN CCN.pdf
PPTX
Business Ethics - An introduction and its overview.pptx
PDF
Power and position in leadershipDOC-20250808-WA0011..pdf
PPTX
5 Stages of group development guide.pptx
PDF
Roadmap Map-digital Banking feature MB,IB,AB
PDF
How to Get Funding for Your Trucking Business
PDF
SIMNET Inc – 2023’s Most Trusted IT Services & Solution Provider
PDF
Katrina Stoneking: Shaking Up the Alcohol Beverage Industry
PDF
Reconciliation AND MEMORANDUM RECONCILATION
PPTX
The Marketing Journey - Tracey Phillips - Marketing Matters 7-2025.pptx
Dr. Enrique Segura Ense Group - A Self-Made Entrepreneur And Executive
Laughter Yoga Basic Learning Workshop Manual
Euro SEO Services 1st 3 General Updates.docx
Ôn tập tiếng anh trong kinh doanh nâng cao
job Avenue by vinith.pptxvnbvnvnvbnvbnbmnbmbh
Traveri Digital Marketing Seminar 2025 by Corey and Jessica Perlman
ICG2025_ICG 6th steering committee 30-8-24.pptx
DOC-20250806-WA0002._20250806_112011_0000.pdf
kom-180-proposal-for-a-directive-amending-directive-2014-45-eu-and-directive-...
Business model innovation report 2022.pdf
BsN 7th Sem Course GridNNNNNNNN CCN.pdf
Business Ethics - An introduction and its overview.pptx
Power and position in leadershipDOC-20250808-WA0011..pdf
5 Stages of group development guide.pptx
Roadmap Map-digital Banking feature MB,IB,AB
How to Get Funding for Your Trucking Business
SIMNET Inc – 2023’s Most Trusted IT Services & Solution Provider
Katrina Stoneking: Shaking Up the Alcohol Beverage Industry
Reconciliation AND MEMORANDUM RECONCILATION
The Marketing Journey - Tracey Phillips - Marketing Matters 7-2025.pptx

Vladyslav Romanchenko "How to keep high code quality without e2e tests"