Slide 1

Slide 1 text

@cowboyd Hi!

Slide 2

Slide 2 text

@cowboyd Unit Testing is a Myth

Slide 3

Slide 3 text

@cowboyd What is a Test?

Slide 4

Slide 4 text

@cowboyd Guarantor of Quality What is a Test?

Slide 5

Slide 5 text

@cowboyd Guide to Design What is a Test?

Slide 6

Slide 6 text

@cowboyd Support Refactoring What is a Test?

Slide 7

Slide 7 text

@cowboyd Test Engineering 5 factor tests* What is a Test? *https://www.devmynd.com/blog/five-factor-testing/

Slide 8

Slide 8 text

@cowboyd Test Science What is a Test?

Slide 9

Slide 9 text

@cowboyd Experiment

Slide 10

Slide 10 text

@cowboyd Unit Experiment it('simulates click events', () => {
 const onButtonClick = sinon.spy();
 const wrapper = shallow((
 
 ));
 wrapper.find('button').simulate('click');
 expect(onButtonClick).to.have.property('callCount', 1);
 });

Slide 11

Slide 11 text

@cowboyd Small Hypothesis A component: • with no parent • with no children • with no external state management (Redux) • with no external sequencer (saga, observable) • running in nodejs • using a simulated DOM • using simulated events Properly dispatches a handler

Slide 12

Slide 12 text

@cowboyd Big Hypothesis A user on a Microsoft Surface can upgrade their the premium subscription with a single click on their settings page.

Slide 13

Slide 13 text

@cowboyd Big vs Small.

Slide 14

Slide 14 text

@cowboyd Big Testing

Slide 15

Slide 15 text

@cowboyd React Today small testing

Slide 16

Slide 16 text

@cowboyd Why not Big Testing?

Slide 17

Slide 17 text

@cowboyd Big Testing is Hard • cumbersome to setup end to end • non-repeatable state management • headaches dealing with asynchrony • coordination with external services

Slide 18

Slide 18 text

@cowboyd Test Engineering

Slide 19

Slide 19 text

@cowboyd Big Testing in React

Slide 20

Slide 20 text

@cowboyd Real Browsers

Slide 21

Slide 21 text

@cowboyd Jest nope. Real Browsers

Slide 22

Slide 22 text

@cowboyd Nightmare nope. Real Browsers

Slide 23

Slide 23 text

@cowboyd Karma https://karma-runner.github.io Real Browsers

Slide 24

Slide 24 text

@cowboyd Karma + BrowserStack Real Browsers

Slide 25

Slide 25 text

@cowboyd Network

Slide 26

Slide 26 text

@cowboyd Slow, Flaky or is it? Network

Slide 27

Slide 27 text

@cowboyd Mirage Server Network

Slide 28

Slide 28 text

@cowboyd Transport, Serialization Network: Mirage Server

Slide 29

Slide 29 text

@cowboyd Factories. Fake Data. Network: Mirage Server

Slide 30

Slide 30 text

@cowboyd Mirage Server Network

Slide 31

Slide 31 text

@cowboyd Asynchrony

Slide 32

Slide 32 text

@cowboyd Asynchrony GOOD Cause Effect time assertion

Slide 33

Slide 33 text

@cowboyd Asynchrony Cause Effect time assertion BAD

Slide 34

Slide 34 text

@cowboyd Convergent Assertions Asynchrony

Slide 35

Slide 35 text

@cowboyd Pure Assertions Asynchrony *gluten free, with 0 side-effects

Slide 36

Slide 36 text

@cowboyd describe("selecting a package title to add to my holdings", function() {
 beforeEach(function() {
 ResourcePage.toggleIsSelected();
 });
 it('reflects the desired state (YES)', function() {
 expect(ResourcePage.isSelected).to.equal(true);
 });
 );

Slide 37

Slide 37 text

@cowboyd Asynchrony BEST Cause Effect time assertions

Slide 38

Slide 38 text

@cowboyd Convergent Assertions Asynchrony Fast!!

Slide 39

Slide 39 text

@cowboyd Demo

Slide 40

Slide 40 text

@cowboyd React: Big Testing https://github.com/cowboyd/react-acceptance-testing https://github.com/thefrontside/ui-eholdings

Slide 41

Slide 41 text

@cowboyd http://frontside.io we’re hiring