SlideShare a Scribd company logo
How to push a ReactJS
application in production
and sleep better
Emanuele Rampichini Application Engineer @spreaker
So, you are
building a
large
ReactJS
single page
application...
2
● Do you need it?
● Are you sure?
● 100% Sure?
● I’m gonna ask it again...
● ARE YOU SURE?
SINGLE PAGE
APPLICATIONS ARE
COMPLEX
3
PnP® APPROACH
4
TESTING AND
MONITORING TO THE
RESCUE
5
Monitor your
ReactJS
application
in production
Monitoring your application in
production is crucial even if you don’t
write tests. The good news is that
nowadays is quite easy
6
● https://sentry.io
● https://newrelic.com
● https://trackjs.com
How to push a react js application in production and sleep better
WHAT ABOUT
TESTING?
8
Let’s start by
defining
some testing
concepts...
Test families ordered from the
cheapest to the most expensive one.
Cost is a mix of write difficulty,
execution time, and maintenance
effort requested.
9
● Unit Tests
● Integration Tests (or midway)
● End 2 End Tests
● Manual Tests
LET’S SEE HOW TO FIT
THIS INSIDE A
REACT + REDUX APP
Useful tools
to do unit
testing in
ReactJs
11
● https://karma-runner.github.io/1
.0/index.html
● http://jasmine.github.io/
● http://phantomjs.org/
● Look for Karma + Webpack +
PhantomJS on google and you
are gonna find a lot of tutorials to
create your setup.
Unit testing a
reducer
function is a
piece of
cake... really!
We are just testing pure functions
(without side effects) in the form:
(State, Action) => State
These tests are very good to ensure
correctness of your state mutation
logic.
12
How to push a react js application in production and sleep better
How to push a react js application in production and sleep better
Unit testing
components
rendering
Given some props we want to ensure
the correctness of the rendered
output.
15
● https://facebook.github.io/react
/docs/test-utils.html
● Shallow Renderer
● https://github.com/sheepsteak
/react-shallow-testutils
● https://github.com/airbnb/enzy
me
How to push a react js application in production and sleep better
How to push a react js application in production and sleep better
How to push a react js application in production and sleep better
How to push a react js application in production and sleep better
How to push a react js application in production and sleep better
Unit testing
components
behaviour
We want to ensure that when
something happens on our
component (lifecycle callbacks, clicks
etc...) the right action get dispatched
to our store.
21
● http://jasmine.github.io/2.0/intr
oduction.html#section-Spies
● Lifecycle: getMountedInstance()
● UI interaction: getOutput()
How to push a react js application in production and sleep better
How to push a react js application in production and sleep better
Unit testing
middlewares
and rich
actions
(thunk)
We want to ensure that a rich action
dispatches the right simple actions
in the right order to our store when
some preconditions are met.
24
● https://github.com/arnaudbenar
d/redux-mock-store
● http://jasmine.github.io/2.0/intr
oduction.html#section-Spies
How to push a react js application in production and sleep better
How to push a react js application in production and sleep better
Midway
testing
We want to test components only
mocking things at the lower level in
our architecture (ex. xhr request).
Every other piece is gonna be the
real application code.
27
● https://github.com/jasmine/jas
mine-ajax
● Setup can be tricky, ensures that
all the pieces are working well
together.
End 2 End
testing with
protractor
In that case we want to interact
directly with our application, we
ignore completely the fact that we
are testing a reactJS app. These tests
are quite slow to run, hard to
maintain and they require full control
of your backend data.
28
● http://www.protractortest.org/
● Expected Conditions
● browser.ignoreSynchronization=true
Manual
testing on
multiple
devices
These test are the most expensive
ones, still they are crucial. Be sure to
have as many real devices as you
can. Here are some tips:
29
● Build your own device wall
● Have a staging environment that
maps 1:1 the production one and
do internal testing.
● Adopt canary deployment
strategies
IT’S NOT HUGE BUT WE
BUILT IT...
30
A LOT OF TESTS TO
WRITE AND TO
MAINTAIN… NOT A LOT
OF TIME 31
▫ It’s OK not to test everything
▫ At first you are gonna be super
slow, then you are gonna
improve. Training is crucial.
▫ If you don’t have time to
implement tests just take some
to write test definitions and
mark them as skipped. You can
add coverage when you have
slack time. (xdescribe, xit )
P.S. WE ARE HIRING,
IF YOU ARE INTERESTED
OR YOU JUST WANT A
T-SHIRT JUST PING ME
Thanks. EMANUELE RAMPICHINI
APPLICATION ENGINEER @spreaker
Get It Touch
emanuele.rampichini@spreaker.com
@emanuele_r

More Related Content

PPTX
Dot all 2019 | Testing with Craft | Giel Tettelar
PDF
Eclipse Day India 2015 - Eclipse RCP testing using Jubula based automation
PDF
100 tests per second - 40 releases per week
PPTX
Development and test infrastructure
PDF
Insights on Protractor testing
PDF
PHPUnit with Magento
PPT
Agile testing for large projects
PDF
Using Crowdsourced Testing to Turbocharge your Development Team
Dot all 2019 | Testing with Craft | Giel Tettelar
Eclipse Day India 2015 - Eclipse RCP testing using Jubula based automation
100 tests per second - 40 releases per week
Development and test infrastructure
Insights on Protractor testing
PHPUnit with Magento
Agile testing for large projects
Using Crowdsourced Testing to Turbocharge your Development Team

What's hot (19)

PPTX
Protractor
PDF
QA Strategies for Testing Legacy Web Apps
PDF
(Js) Export your own WebGL Viewer
PDF
Automated tests types on Magento 2 example
PPTX
Mastering Test Automation: How To Use Selenium Successfully
PPTX
Continuous integration CloudParty 21 may 2014 - Milan
PDF
Unit Testing your React / Redux app (@BucharestJS)
PPT
Continuous Integration
PDF
Dicoding Developer Coaching #13: Android | Melakukan Testing secara Otomatis ...
PPTX
Migration from AngularJS to Angular
PPTX
Test Automation Pyramid
PDF
Agile Testing…or Walking Dead Testing?
PPT
Игорь Бондаренко (Neklo) - Организация процесса разработки модулей для Magento
PDF
Put "fast" back in "fast feedback"
PDF
Integration Testing in Enterprises using TaaS
PDF
How to go about testing in React?
PPT
Qtp testing
PDF
TestWorks Conf Performance testing made easy with gatling - Guillaume Corré
PDF
Tasting Your First Test Burger
Protractor
QA Strategies for Testing Legacy Web Apps
(Js) Export your own WebGL Viewer
Automated tests types on Magento 2 example
Mastering Test Automation: How To Use Selenium Successfully
Continuous integration CloudParty 21 may 2014 - Milan
Unit Testing your React / Redux app (@BucharestJS)
Continuous Integration
Dicoding Developer Coaching #13: Android | Melakukan Testing secara Otomatis ...
Migration from AngularJS to Angular
Test Automation Pyramid
Agile Testing…or Walking Dead Testing?
Игорь Бондаренко (Neklo) - Организация процесса разработки модулей для Magento
Put "fast" back in "fast feedback"
Integration Testing in Enterprises using TaaS
How to go about testing in React?
Qtp testing
TestWorks Conf Performance testing made easy with gatling - Guillaume Corré
Tasting Your First Test Burger
Ad

Similar to How to push a react js application in production and sleep better (20)

PPTX
Dive into Angular, part 5: Experience
PPTX
Open Source Power Tools - Opensouthcode 2018-06-02
PDF
Automated Testing in Angular Slides
PDF
JavaOne 2017 CON2902 - Java Code Inspection and Testing Power Tools
PDF
Testing Vue Apps with Cypress.io (STLJS Meetup April 2018)
PDF
DCVCS using GIT
PDF
Gatling - Bordeaux JUG
PDF
Testing in FrontEnd World by Nikita Galkin
PPTX
Pain Driven Development by Alexandr Sugak
PPTX
Vue.js Use Cases
ODP
RandomTest - Random Software Integration Tests That Just Work for C/C++, Java...
PDF
Wso2con test-automation
PDF
Unit testing for ext js apps using sencha test - Walkingtree Technologies
PDF
Play with Testing on Android - Gilang Ramadhan (Academy Content Writer at Dic...
PDF
What is the best approach to tdd
PDF
Real World AngularJS recipes: beyond TodoMVC
PDF
Real World AngularJS recipes: beyond TodoMVC - Carlo Bonamico, Sonia Pini - C...
PDF
Agile A to Z Chapter 4 Feedback Loop Part 2 DevOps
PDF
Introduction to Unit Tests and TDD
PDF
A Comprehensive Guide to Conducting Test Automation Using Appium & Cucumber o...
Dive into Angular, part 5: Experience
Open Source Power Tools - Opensouthcode 2018-06-02
Automated Testing in Angular Slides
JavaOne 2017 CON2902 - Java Code Inspection and Testing Power Tools
Testing Vue Apps with Cypress.io (STLJS Meetup April 2018)
DCVCS using GIT
Gatling - Bordeaux JUG
Testing in FrontEnd World by Nikita Galkin
Pain Driven Development by Alexandr Sugak
Vue.js Use Cases
RandomTest - Random Software Integration Tests That Just Work for C/C++, Java...
Wso2con test-automation
Unit testing for ext js apps using sencha test - Walkingtree Technologies
Play with Testing on Android - Gilang Ramadhan (Academy Content Writer at Dic...
What is the best approach to tdd
Real World AngularJS recipes: beyond TodoMVC
Real World AngularJS recipes: beyond TodoMVC - Carlo Bonamico, Sonia Pini - C...
Agile A to Z Chapter 4 Feedback Loop Part 2 DevOps
Introduction to Unit Tests and TDD
A Comprehensive Guide to Conducting Test Automation Using Appium & Cucumber o...
Ad

More from Emanuele Rampichini (8)

PDF
What is quality? Why should i care?
PDF
I segreti di una campagna di crowdfunding civico di successo
PDF
Lavorare con tecnologie "Cool" senza rinunciare all'accessibilità
PDF
Building a Desktop Streaming console with Electron and ReactJS
PDF
Building a Desktop Streaming console with Node.js and WebKit
PDF
Speed up your Titanium app development with automated tests - TiConf EU 2014
PDF
AngularDevConf - Tools and testing
PDF
Coderetreat 2013 @cowo42 (Osimo - AN)
What is quality? Why should i care?
I segreti di una campagna di crowdfunding civico di successo
Lavorare con tecnologie "Cool" senza rinunciare all'accessibilità
Building a Desktop Streaming console with Electron and ReactJS
Building a Desktop Streaming console with Node.js and WebKit
Speed up your Titanium app development with automated tests - TiConf EU 2014
AngularDevConf - Tools and testing
Coderetreat 2013 @cowo42 (Osimo - AN)

Recently uploaded (20)

PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
How Creative Agencies Leverage Project Management Software.pdf
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PPTX
Odoo POS Development Services by CandidRoot Solutions
PDF
Digital Strategies for Manufacturing Companies
PPTX
Introduction to Artificial Intelligence
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PPTX
history of c programming in notes for students .pptx
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Upgrade and Innovation Strategies for SAP ERP Customers
Operating system designcfffgfgggggggvggggggggg
How to Migrate SBCGlobal Email to Yahoo Easily
VVF-Customer-Presentation2025-Ver1.9.pptx
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Navsoft: AI-Powered Business Solutions & Custom Software Development
How Creative Agencies Leverage Project Management Software.pdf
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Which alternative to Crystal Reports is best for small or large businesses.pdf
Odoo POS Development Services by CandidRoot Solutions
Digital Strategies for Manufacturing Companies
Introduction to Artificial Intelligence
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
history of c programming in notes for students .pptx
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
Design an Analysis of Algorithms I-SECS-1021-03
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
How to Choose the Right IT Partner for Your Business in Malaysia
Internet Downloader Manager (IDM) Crack 6.42 Build 41

How to push a react js application in production and sleep better

  • 1. How to push a ReactJS application in production and sleep better Emanuele Rampichini Application Engineer @spreaker
  • 2. So, you are building a large ReactJS single page application... 2 ● Do you need it? ● Are you sure? ● 100% Sure? ● I’m gonna ask it again... ● ARE YOU SURE?
  • 6. Monitor your ReactJS application in production Monitoring your application in production is crucial even if you don’t write tests. The good news is that nowadays is quite easy 6 ● https://sentry.io ● https://newrelic.com ● https://trackjs.com
  • 9. Let’s start by defining some testing concepts... Test families ordered from the cheapest to the most expensive one. Cost is a mix of write difficulty, execution time, and maintenance effort requested. 9 ● Unit Tests ● Integration Tests (or midway) ● End 2 End Tests ● Manual Tests
  • 10. LET’S SEE HOW TO FIT THIS INSIDE A REACT + REDUX APP
  • 11. Useful tools to do unit testing in ReactJs 11 ● https://karma-runner.github.io/1 .0/index.html ● http://jasmine.github.io/ ● http://phantomjs.org/ ● Look for Karma + Webpack + PhantomJS on google and you are gonna find a lot of tutorials to create your setup.
  • 12. Unit testing a reducer function is a piece of cake... really! We are just testing pure functions (without side effects) in the form: (State, Action) => State These tests are very good to ensure correctness of your state mutation logic. 12
  • 15. Unit testing components rendering Given some props we want to ensure the correctness of the rendered output. 15 ● https://facebook.github.io/react /docs/test-utils.html ● Shallow Renderer ● https://github.com/sheepsteak /react-shallow-testutils ● https://github.com/airbnb/enzy me
  • 21. Unit testing components behaviour We want to ensure that when something happens on our component (lifecycle callbacks, clicks etc...) the right action get dispatched to our store. 21 ● http://jasmine.github.io/2.0/intr oduction.html#section-Spies ● Lifecycle: getMountedInstance() ● UI interaction: getOutput()
  • 24. Unit testing middlewares and rich actions (thunk) We want to ensure that a rich action dispatches the right simple actions in the right order to our store when some preconditions are met. 24 ● https://github.com/arnaudbenar d/redux-mock-store ● http://jasmine.github.io/2.0/intr oduction.html#section-Spies
  • 27. Midway testing We want to test components only mocking things at the lower level in our architecture (ex. xhr request). Every other piece is gonna be the real application code. 27 ● https://github.com/jasmine/jas mine-ajax ● Setup can be tricky, ensures that all the pieces are working well together.
  • 28. End 2 End testing with protractor In that case we want to interact directly with our application, we ignore completely the fact that we are testing a reactJS app. These tests are quite slow to run, hard to maintain and they require full control of your backend data. 28 ● http://www.protractortest.org/ ● Expected Conditions ● browser.ignoreSynchronization=true
  • 29. Manual testing on multiple devices These test are the most expensive ones, still they are crucial. Be sure to have as many real devices as you can. Here are some tips: 29 ● Build your own device wall ● Have a staging environment that maps 1:1 the production one and do internal testing. ● Adopt canary deployment strategies
  • 30. IT’S NOT HUGE BUT WE BUILT IT... 30
  • 31. A LOT OF TESTS TO WRITE AND TO MAINTAIN… NOT A LOT OF TIME 31
  • 32. ▫ It’s OK not to test everything ▫ At first you are gonna be super slow, then you are gonna improve. Training is crucial. ▫ If you don’t have time to implement tests just take some to write test definitions and mark them as skipped. You can add coverage when you have slack time. (xdescribe, xit )
  • 33. P.S. WE ARE HIRING, IF YOU ARE INTERESTED OR YOU JUST WANT A T-SHIRT JUST PING ME
  • 34. Thanks. EMANUELE RAMPICHINI APPLICATION ENGINEER @spreaker Get It Touch [email protected] @emanuele_r