SlideShare a Scribd company logo
Front End Workshops
React Testing
Cristina Hernández García
chernandez@visual-engin.com
Mario García Martín
mgarcia@visual-engin.com
JavaScript Testing
Remember, remember...
Testing basics
Tools we’ll be using
describe("Use describe to group similar tests", function() {
});
Test framework Assertions library Test spies, stubs and mocks
*More info at http://mochajs.org/, http://chaijs.com/, and http://sinonjs.org/
describe
suite hooks
it
expect
beforeEach(function() {});
afterEach(function() {});
it("use it to test an attribute of a target", function() {
});
// use expect to make an assertion about a target
expect(foo).to.be.a('string');
expect(foo).to.equal('bar');
Test Driven Development (TDD)
The cycle of TDD
Benefits of TDD
Produces code that works
Honors the Single Responsibility Principle
Forces conscious development
Productivity boost
Run tests
Write a
test
Run tests
Make the
test pass
Refactor
Test Driven Development (TDD)
The cycle of TDD
Benefits of TDD
Produces code that works
Honors the Single Responsibility Principle
Forces conscious development
Productivity boost
Run tests
Write a
test
Run tests
Make the
test pass
Refactor
Testing React applications
What’s different?
React testing - Particularities (1 of 2)
Although not always required, sometimes it’s necessary to have a full DOM
API.
Components are rendered to a VDOM...
No need to fully render our components while testing!
global.document = jsdom.jsdom('<!doctype html><html><body></body></html>');
global.window = global.document.defaultView;
global.navigator = {
userAgent: 'node.js'
};
For console-based testing environments you can use the jsdom library to mock
the DOM document.
React testing - Particularities
Events simulation is needed
Components are rendered to a VDOM...
Higher level components can be tested in isolation. Shallow rendering.
View
ViewView
View View View View View
Lets you render a
component “one level
deep”.
You don’t have to worry
about the behavior of
child components.
React test utilities
Makes it easy to test React components in
the testing framework of your choice.
React test utilities (1 of 3) (react-addons-test-utils)
ReactComponent renderIntoDocument(ReactElement instance)
Render a component into a detached DOM node in the document.
Requires a full DOM API available at the global scope.
It does not require a DOM API.
ReactShallowRenderer
createRenderer()
shallowRenderer.render(ReactElement element)
ReactElement shallowRenderer.getRenderOutput()
Rendering components
Shallow rendering
React test utilities (2 of 3) (react-addons-test-utils)
Shallow rendering example
// MyComponent.js
import React, { Component } from
'react';
import Subcomponent from
'./Subcomponent';
class MyComponent extends Component {
render() {
return (
<div>
<span className="heading">
Title
</span>
<Subcomponent foo="bar" />
</div>
);
}
}
export default MyComponent;
// MyComponent.spec.js
import React from 'react';
import TestUtils from
'react-addons-test-utils';
import MyComponent from 'mycomponent';
const renderer =
TestUtils.createRenderer();
renderer.render(<MyComponent />);
const result =
renderer.getRenderOutput();
expect(result.type).to.equal('div');
expect(result.props.children).to.eql([
<span className="heading">Title</span>,
<Subcomponent foo="bar" />
]);
React test utilities (3 of 3) (react-addons-test-utils)
findAllInRenderedTree
scryRenderedDOMComponentsWithClass
findRenderedDOMComponentWithClass
scryRenderedDOMComponentsWithTag
findRenderedDOMComponentWithTag
scryRenderedDOMComponentsWithType
findRenderedDOMComponentWithType
Simulate an event dispatch on a DOM node with optional event data.
Simulate.{eventName}(DOMElement element, [object eventData])
Simulating React synthetic events
The rendered components interface...
Enzyme
JavaScript Testing utility for React.
Enzyme - Introduction
Now, with 150% neater interface!
.find(selector)
.findWhere(predicate)
.state([key])
.setState(nextState)
.prop([key])
.setProps(nextProps)
.parent()
.children()
.simulate(event[,
data])
.update()
.debug()
*The render function may not have all the methods advertised
Mimicks jQuery’s API DOM manipulation and traversal.
rendermountshallow
Enzyme - Shallow rendering
shallow(node[, options]) => ShallowWrapper
*More info at http://airbnb.io/enzyme/docs/api/shallow.html
const row = shallow(<TableRow columns={5} />)
// Using prop to retrieve the columns
property
expect(row.prop('columns')).to.eql(5);
// Using 'at' to retrieve the forth column's
content
expect(row.find(TableColumn).at(3).prop('content')).to.exist;
// Using first and text to retrieve the columns text
content
expect(row.find(TableColumn).first().text()).to.eql('First column');
// Simulating events
const button = shallow(<MyButton
/>);
button.simulate('click');
expect(button.state('myActionWasPerformed')).to.be.true;
Enzyme - Full DOM rendering
mount(node[, options]) => ReactWrapper
*More info at http://airbnb.io/enzyme/docs/api/mount.html
Use it when interacting with DOM or testing full lifecycle (componentDidMount).
it('calls componentDidMount', function() {
spy(Foo.prototype, 'componentDidMount');
const wrapper = mount(<Foo />);
expect(Foo.prototype.componentDidMount.calledOnce).to.equal(true);
});
it('allows us to set props', function() {
const wrapper = mount(<Foo bar='baz' />);
expect(wrapper.prop('bar')).to.equal('baz');
wrapper.setProps({ bar: 'foo' });
expect(wrapper.props('bar')).to.equal('foo');
});
Requires a full DOM API available at the global scope.
Enzyme - Static rendered markup
render(node[, options]) => CheerioWrapper
*More info at http://airbnb.io/enzyme/docs/api/render.html
Use it to render react components into static HTML (Uses Cheerio library).
it('renders three .foo-bar', function() {
const wrapper = render(<Foo />);
expect(wrapper.find('.foo-bar')).to.have.length(3);
});
it('rendered the title', function() {
const wrapper = render(<Foo title="unique" />);
expect(wrapper.text()).to.contain("unique");
});
Hands on code
Simpsons Wheel
Simpsons Wheel - General overview
App
generateRandInfo(<value>)
type: GENERATE_RANDINFO
payload: { value: 1, timestamp: 1234}
Reducers
STATE
randInfo: { value: 1, timestamp: 1234 }
Wheel
Button
Simpsons Wheel - Component details (1 of 2)
App component
Renders Wheel component, passing items prop
Renders Button component, passing max prop
Button component
Receives a max prop
When clicked, computes a random value between 1 and max
Calls action creator with the random number
Simpsons Wheel - Component details (2 of 2)
Wheel component
Renders the images
Stores the carousel
rotation in its state
Listens to Redux state
changes
Updates the rotation when
receives new props
Thanks for your time!
Do you have any questions?
Workshop 23: ReactJS, React & Redux testing

More Related Content

What's hot (20)

PDF
Workshop 20: ReactJS Part II Flux Pattern & Redux
Visual Engineering
 
PDF
Workshop 22: React-Redux Middleware
Visual Engineering
 
PDF
Workshop 5: JavaScript testing
Visual Engineering
 
PDF
Redux Sagas - React Alicante
Ignacio Martín
 
PDF
Protocol-Oriented MVVM (extended edition)
Natasha Murashev
 
PDF
Reactive, component 그리고 angular2
Jeado Ko
 
PDF
Swift Delhi: Practical POP
Natasha Murashev
 
PDF
Practical Protocol-Oriented-Programming
Natasha Murashev
 
PDF
Workshop 12: AngularJS Parte I
Visual Engineering
 
PDF
Protocol-Oriented MVVM
Natasha Murashev
 
PDF
«От экспериментов с инфраструктурой до внедрения в продакшен»​
FDConf
 
PDF
Workshop 8: Templating: Handlebars, DustJS
Visual Engineering
 
PDF
Using React, Redux and Saga with Lottoland APIs
Mihail Gaberov
 
PDF
Workshop 3: JavaScript build tools
Visual Engineering
 
PDF
How Angular2 Can Improve Your AngularJS Apps Today!
Nir Kaufman
 
PPTX
Typescript barcelona
Christoffer Noring
 
PDF
Building scalable applications with angular js
Andrew Alpert
 
PDF
React Native One Day
Troy Miles
 
PDF
Async JavaScript Unit Testing
Mihail Gaberov
 
PDF
Kotlin Delegates in practice - Kotlin community conf
Fabio Collini
 
Workshop 20: ReactJS Part II Flux Pattern & Redux
Visual Engineering
 
Workshop 22: React-Redux Middleware
Visual Engineering
 
Workshop 5: JavaScript testing
Visual Engineering
 
Redux Sagas - React Alicante
Ignacio Martín
 
Protocol-Oriented MVVM (extended edition)
Natasha Murashev
 
Reactive, component 그리고 angular2
Jeado Ko
 
Swift Delhi: Practical POP
Natasha Murashev
 
Practical Protocol-Oriented-Programming
Natasha Murashev
 
Workshop 12: AngularJS Parte I
Visual Engineering
 
Protocol-Oriented MVVM
Natasha Murashev
 
«От экспериментов с инфраструктурой до внедрения в продакшен»​
FDConf
 
Workshop 8: Templating: Handlebars, DustJS
Visual Engineering
 
Using React, Redux and Saga with Lottoland APIs
Mihail Gaberov
 
Workshop 3: JavaScript build tools
Visual Engineering
 
How Angular2 Can Improve Your AngularJS Apps Today!
Nir Kaufman
 
Typescript barcelona
Christoffer Noring
 
Building scalable applications with angular js
Andrew Alpert
 
React Native One Day
Troy Miles
 
Async JavaScript Unit Testing
Mihail Gaberov
 
Kotlin Delegates in practice - Kotlin community conf
Fabio Collini
 

Similar to Workshop 23: ReactJS, React & Redux testing (20)

PDF
Annotation Processing
Jintin Lin
 
PPTX
Protractor framework architecture with example
shadabgilani
 
PPTX
In search of JavaScript code quality: unit testing
Anna Khabibullina
 
KEY
Javascript unit testing, yes we can e big
Andy Peterson
 
PPTX
Nevermore Unit Testing
Ihsan Fauzi Rahman
 
PPTX
Junit_.pptx
Suman Sourav
 
PDF
Fundamental Concepts of React JS for Beginners.pdf
StephieJohn
 
KEY
JavaScript Growing Up
David Padbury
 
PPT
JavaScript Basics
Mats Bryntse
 
PDF
Javascript tdd byandreapaciolla
Andrea Paciolla
 
PDF
Javascript Frameworks for Joomla
Luke Summerfield
 
PPT
比XML更好用的Java Annotation
javatwo2011
 
ODP
Grails unit testing
pleeps
 
PPTX
Adding a modern twist to legacy web applications
Jeff Durta
 
PDF
MeetJS Summit 2016: React.js enlightenment
Artur Szott
 
ODP
Bring the fun back to java
ciklum_ods
 
PDF
Release with confidence
John Congdon
 
PDF
Build Web Apps using Node.js
davidchubbs
 
PPTX
react-slides.pptx
DayNightGaMiNg
 
ODP
Unit Testing and Coverage for AngularJS
Knoldus Inc.
 
Annotation Processing
Jintin Lin
 
Protractor framework architecture with example
shadabgilani
 
In search of JavaScript code quality: unit testing
Anna Khabibullina
 
Javascript unit testing, yes we can e big
Andy Peterson
 
Nevermore Unit Testing
Ihsan Fauzi Rahman
 
Junit_.pptx
Suman Sourav
 
Fundamental Concepts of React JS for Beginners.pdf
StephieJohn
 
JavaScript Growing Up
David Padbury
 
JavaScript Basics
Mats Bryntse
 
Javascript tdd byandreapaciolla
Andrea Paciolla
 
Javascript Frameworks for Joomla
Luke Summerfield
 
比XML更好用的Java Annotation
javatwo2011
 
Grails unit testing
pleeps
 
Adding a modern twist to legacy web applications
Jeff Durta
 
MeetJS Summit 2016: React.js enlightenment
Artur Szott
 
Bring the fun back to java
ciklum_ods
 
Release with confidence
John Congdon
 
Build Web Apps using Node.js
davidchubbs
 
react-slides.pptx
DayNightGaMiNg
 
Unit Testing and Coverage for AngularJS
Knoldus Inc.
 
Ad

More from Visual Engineering (17)

PDF
Workshop 27: Isomorphic web apps with ReactJS
Visual Engineering
 
PDF
Workshop iOS 4: Closures, generics & operators
Visual Engineering
 
PDF
Workshop iOS 3: Testing, protocolos y extensiones
Visual Engineering
 
PDF
Workshop iOS 2: Swift - Structures
Visual Engineering
 
PDF
Workhop iOS 1: Fundamentos de Swift
Visual Engineering
 
PDF
Workshop 22: ReactJS Redux Advanced
Visual Engineering
 
PDF
Workshop 21: React Router
Visual Engineering
 
PDF
Workshop 18: CSS Animations & cool effects
Visual Engineering
 
PDF
Workshop 16: EmberJS Parte I
Visual Engineering
 
PDF
Workshop 15: Ionic framework
Visual Engineering
 
PDF
Workshop 11: Trendy web designs & prototyping
Visual Engineering
 
PDF
Workshop 10: ECMAScript 6
Visual Engineering
 
PDF
Workshop 9: BackboneJS y patrones MVC
Visual Engineering
 
PDF
Workshop 7: Single Page Applications
Visual Engineering
 
PDF
Workshop 6: Designer tools
Visual Engineering
 
PDF
Workshop 4: NodeJS. Express Framework & MongoDB.
Visual Engineering
 
PDF
Workshop 2: JavaScript Design Patterns
Visual Engineering
 
Workshop 27: Isomorphic web apps with ReactJS
Visual Engineering
 
Workshop iOS 4: Closures, generics & operators
Visual Engineering
 
Workshop iOS 3: Testing, protocolos y extensiones
Visual Engineering
 
Workshop iOS 2: Swift - Structures
Visual Engineering
 
Workhop iOS 1: Fundamentos de Swift
Visual Engineering
 
Workshop 22: ReactJS Redux Advanced
Visual Engineering
 
Workshop 21: React Router
Visual Engineering
 
Workshop 18: CSS Animations & cool effects
Visual Engineering
 
Workshop 16: EmberJS Parte I
Visual Engineering
 
Workshop 15: Ionic framework
Visual Engineering
 
Workshop 11: Trendy web designs & prototyping
Visual Engineering
 
Workshop 10: ECMAScript 6
Visual Engineering
 
Workshop 9: BackboneJS y patrones MVC
Visual Engineering
 
Workshop 7: Single Page Applications
Visual Engineering
 
Workshop 6: Designer tools
Visual Engineering
 
Workshop 4: NodeJS. Express Framework & MongoDB.
Visual Engineering
 
Workshop 2: JavaScript Design Patterns
Visual Engineering
 
Ad

Recently uploaded (20)

PDF
Capcut Pro Crack For PC Latest Version {Fully Unlocked} 2025
hashhshs786
 
PDF
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
PPTX
Tally software_Introduction_Presentation
AditiBansal54083
 
PPTX
Engineering the Java Web Application (MVC)
abhishekoza1981
 
PPTX
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
PPTX
The Role of a PHP Development Company in Modern Web Development
SEO Company for School in Delhi NCR
 
PPTX
Equipment Management Software BIS Safety UK.pptx
BIS Safety Software
 
PDF
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
PPTX
Java Native Memory Leaks: The Hidden Villain Behind JVM Performance Issues
Tier1 app
 
PPTX
Comprehensive Guide: Shoviv Exchange to Office 365 Migration Tool 2025
Shoviv Software
 
PPTX
Migrating Millions of Users with Debezium, Apache Kafka, and an Acyclic Synch...
MD Sayem Ahmed
 
PPTX
Revolutionizing Code Modernization with AI
KrzysztofKkol1
 
PPTX
Platform for Enterprise Solution - Java EE5
abhishekoza1981
 
PDF
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
PDF
Mobile CMMS Solutions Empowering the Frontline Workforce
CryotosCMMSSoftware
 
PDF
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
PDF
Beyond Binaries: Understanding Diversity and Allyship in a Global Workplace -...
Imma Valls Bernaus
 
PPTX
How Apagen Empowered an EPC Company with Engineering ERP Software
SatishKumar2651
 
PDF
Linux Certificate of Completion - LabEx Certificate
VICTOR MAESTRE RAMIREZ
 
PPTX
3uTools Full Crack Free Version Download [Latest] 2025
muhammadgurbazkhan
 
Capcut Pro Crack For PC Latest Version {Fully Unlocked} 2025
hashhshs786
 
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
Tally software_Introduction_Presentation
AditiBansal54083
 
Engineering the Java Web Application (MVC)
abhishekoza1981
 
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
The Role of a PHP Development Company in Modern Web Development
SEO Company for School in Delhi NCR
 
Equipment Management Software BIS Safety UK.pptx
BIS Safety Software
 
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
Java Native Memory Leaks: The Hidden Villain Behind JVM Performance Issues
Tier1 app
 
Comprehensive Guide: Shoviv Exchange to Office 365 Migration Tool 2025
Shoviv Software
 
Migrating Millions of Users with Debezium, Apache Kafka, and an Acyclic Synch...
MD Sayem Ahmed
 
Revolutionizing Code Modernization with AI
KrzysztofKkol1
 
Platform for Enterprise Solution - Java EE5
abhishekoza1981
 
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
Mobile CMMS Solutions Empowering the Frontline Workforce
CryotosCMMSSoftware
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
Beyond Binaries: Understanding Diversity and Allyship in a Global Workplace -...
Imma Valls Bernaus
 
How Apagen Empowered an EPC Company with Engineering ERP Software
SatishKumar2651
 
Linux Certificate of Completion - LabEx Certificate
VICTOR MAESTRE RAMIREZ
 
3uTools Full Crack Free Version Download [Latest] 2025
muhammadgurbazkhan
 

Workshop 23: ReactJS, React & Redux testing

  • 1. Front End Workshops React Testing Cristina Hernández García [email protected] Mario García Martín [email protected]
  • 3. Testing basics Tools we’ll be using describe("Use describe to group similar tests", function() { }); Test framework Assertions library Test spies, stubs and mocks *More info at http://mochajs.org/, http://chaijs.com/, and http://sinonjs.org/ describe suite hooks it expect beforeEach(function() {}); afterEach(function() {}); it("use it to test an attribute of a target", function() { }); // use expect to make an assertion about a target expect(foo).to.be.a('string'); expect(foo).to.equal('bar');
  • 4. Test Driven Development (TDD) The cycle of TDD Benefits of TDD Produces code that works Honors the Single Responsibility Principle Forces conscious development Productivity boost Run tests Write a test Run tests Make the test pass Refactor
  • 5. Test Driven Development (TDD) The cycle of TDD Benefits of TDD Produces code that works Honors the Single Responsibility Principle Forces conscious development Productivity boost Run tests Write a test Run tests Make the test pass Refactor
  • 7. React testing - Particularities (1 of 2) Although not always required, sometimes it’s necessary to have a full DOM API. Components are rendered to a VDOM... No need to fully render our components while testing! global.document = jsdom.jsdom('<!doctype html><html><body></body></html>'); global.window = global.document.defaultView; global.navigator = { userAgent: 'node.js' }; For console-based testing environments you can use the jsdom library to mock the DOM document.
  • 8. React testing - Particularities Events simulation is needed Components are rendered to a VDOM... Higher level components can be tested in isolation. Shallow rendering. View ViewView View View View View View Lets you render a component “one level deep”. You don’t have to worry about the behavior of child components.
  • 9. React test utilities Makes it easy to test React components in the testing framework of your choice.
  • 10. React test utilities (1 of 3) (react-addons-test-utils) ReactComponent renderIntoDocument(ReactElement instance) Render a component into a detached DOM node in the document. Requires a full DOM API available at the global scope. It does not require a DOM API. ReactShallowRenderer createRenderer() shallowRenderer.render(ReactElement element) ReactElement shallowRenderer.getRenderOutput() Rendering components Shallow rendering
  • 11. React test utilities (2 of 3) (react-addons-test-utils) Shallow rendering example // MyComponent.js import React, { Component } from 'react'; import Subcomponent from './Subcomponent'; class MyComponent extends Component { render() { return ( <div> <span className="heading"> Title </span> <Subcomponent foo="bar" /> </div> ); } } export default MyComponent; // MyComponent.spec.js import React from 'react'; import TestUtils from 'react-addons-test-utils'; import MyComponent from 'mycomponent'; const renderer = TestUtils.createRenderer(); renderer.render(<MyComponent />); const result = renderer.getRenderOutput(); expect(result.type).to.equal('div'); expect(result.props.children).to.eql([ <span className="heading">Title</span>, <Subcomponent foo="bar" /> ]);
  • 12. React test utilities (3 of 3) (react-addons-test-utils) findAllInRenderedTree scryRenderedDOMComponentsWithClass findRenderedDOMComponentWithClass scryRenderedDOMComponentsWithTag findRenderedDOMComponentWithTag scryRenderedDOMComponentsWithType findRenderedDOMComponentWithType Simulate an event dispatch on a DOM node with optional event data. Simulate.{eventName}(DOMElement element, [object eventData]) Simulating React synthetic events The rendered components interface...
  • 14. Enzyme - Introduction Now, with 150% neater interface! .find(selector) .findWhere(predicate) .state([key]) .setState(nextState) .prop([key]) .setProps(nextProps) .parent() .children() .simulate(event[, data]) .update() .debug() *The render function may not have all the methods advertised Mimicks jQuery’s API DOM manipulation and traversal. rendermountshallow
  • 15. Enzyme - Shallow rendering shallow(node[, options]) => ShallowWrapper *More info at http://airbnb.io/enzyme/docs/api/shallow.html const row = shallow(<TableRow columns={5} />) // Using prop to retrieve the columns property expect(row.prop('columns')).to.eql(5); // Using 'at' to retrieve the forth column's content expect(row.find(TableColumn).at(3).prop('content')).to.exist; // Using first and text to retrieve the columns text content expect(row.find(TableColumn).first().text()).to.eql('First column'); // Simulating events const button = shallow(<MyButton />); button.simulate('click'); expect(button.state('myActionWasPerformed')).to.be.true;
  • 16. Enzyme - Full DOM rendering mount(node[, options]) => ReactWrapper *More info at http://airbnb.io/enzyme/docs/api/mount.html Use it when interacting with DOM or testing full lifecycle (componentDidMount). it('calls componentDidMount', function() { spy(Foo.prototype, 'componentDidMount'); const wrapper = mount(<Foo />); expect(Foo.prototype.componentDidMount.calledOnce).to.equal(true); }); it('allows us to set props', function() { const wrapper = mount(<Foo bar='baz' />); expect(wrapper.prop('bar')).to.equal('baz'); wrapper.setProps({ bar: 'foo' }); expect(wrapper.props('bar')).to.equal('foo'); }); Requires a full DOM API available at the global scope.
  • 17. Enzyme - Static rendered markup render(node[, options]) => CheerioWrapper *More info at http://airbnb.io/enzyme/docs/api/render.html Use it to render react components into static HTML (Uses Cheerio library). it('renders three .foo-bar', function() { const wrapper = render(<Foo />); expect(wrapper.find('.foo-bar')).to.have.length(3); }); it('rendered the title', function() { const wrapper = render(<Foo title="unique" />); expect(wrapper.text()).to.contain("unique"); });
  • 19. Simpsons Wheel - General overview App generateRandInfo(<value>) type: GENERATE_RANDINFO payload: { value: 1, timestamp: 1234} Reducers STATE randInfo: { value: 1, timestamp: 1234 } Wheel Button
  • 20. Simpsons Wheel - Component details (1 of 2) App component Renders Wheel component, passing items prop Renders Button component, passing max prop Button component Receives a max prop When clicked, computes a random value between 1 and max Calls action creator with the random number
  • 21. Simpsons Wheel - Component details (2 of 2) Wheel component Renders the images Stores the carousel rotation in its state Listens to Redux state changes Updates the rotation when receives new props
  • 22. Thanks for your time! Do you have any questions?