daniel stern - mastering react testing with jest

63

Upload: abdurrachman-mappuji

Post on 12-Apr-2017

158 views

Category:

Engineering


14 download

TRANSCRIPT

Page 1: Daniel Stern - Mastering React Testing with Jest
Page 2: Daniel Stern - Mastering React Testing with Jest
Page 3: Daniel Stern - Mastering React Testing with Jest
Page 4: Daniel Stern - Mastering React Testing with Jest
Page 5: Daniel Stern - Mastering React Testing with Jest
Page 6: Daniel Stern - Mastering React Testing with Jest
Page 7: Daniel Stern - Mastering React Testing with Jest
Page 8: Daniel Stern - Mastering React Testing with Jest

// __tests__/sum-test.jsjest.dontMock('../sum');

describe('sum', function() { it('adds 1 + 2 to equal 3', function() {

var sum = require('../sum'); expect(sum(1, 2)).toBe(3);

}); });

require

Page 9: Daniel Stern - Mastering React Testing with Jest

require

Page 10: Daniel Stern - Mastering React Testing with Jest

require

Page 11: Daniel Stern - Mastering React Testing with Jest
Page 12: Daniel Stern - Mastering React Testing with Jest
Page 13: Daniel Stern - Mastering React Testing with Jest
Page 14: Daniel Stern - Mastering React Testing with Jest
Page 15: Daniel Stern - Mastering React Testing with Jest
Page 16: Daniel Stern - Mastering React Testing with Jest
Page 17: Daniel Stern - Mastering React Testing with Jest
Page 18: Daniel Stern - Mastering React Testing with Jest
Page 19: Daniel Stern - Mastering React Testing with Jest
Page 20: Daniel Stern - Mastering React Testing with Jest
Page 21: Daniel Stern - Mastering React Testing with Jest
Page 22: Daniel Stern - Mastering React Testing with Jest
Page 23: Daniel Stern - Mastering React Testing with Jest

[jest.dontMock(“myModule”)]

Page 24: Daniel Stern - Mastering React Testing with Jest
Page 25: Daniel Stern - Mastering React Testing with Jest

jest.autoMockOn()

jest.autoMockOff()

Page 27: Daniel Stern - Mastering React Testing with Jest

__mocks__

Page 28: Daniel Stern - Mastering React Testing with Jest
Page 29: Daniel Stern - Mastering React Testing with Jest

expect(value).toBe(other)

Page 30: Daniel Stern - Mastering React Testing with Jest

beforeEachafterEach

describe()

it()

expect assert

Page 31: Daniel Stern - Mastering React Testing with Jest
Page 32: Daniel Stern - Mastering React Testing with Jest

new

mock

toBeCalled toBeCalledWith

Page 33: Daniel Stern - Mastering React Testing with Jest

Github – danielstern | @danieljackstern

Daniel Stern

Building a Test-Ready React Application with ES6 and Express

Page 34: Daniel Stern - Mastering React Testing with Jest

Application Overview

App

isomorphismlocalization express

Non-trivial isomorphic shopping cart

application with currency localization

Page 35: Daniel Stern - Mastering React Testing with Jest

This slide is

with

animations

Babel processes ES6 and JSX via Gulp

Express responds to HTTP requests from the

browser by serving our application

React runs on the front and back end,

facilitating everything the user sees and

interacts with and minimizing performance

issues

Page 36: Daniel Stern - Mastering React Testing with Jest

Application shares numerous technologies with app from Build a

Full Stack with React and Express Pluralsight, Daniel Stern

If you have course files, you can skip this chapter by checking

out the appropriate Git Branch

Before We Begin

Page 37: Daniel Stern - Mastering React Testing with Jest

Demo

This bullet list is

with

animations

Constructing the App

Page 38: Daniel Stern - Mastering React Testing with Jest

This bullet list is

with

animations

Fully functional cart application

total and currency localization with React

Real-world dependency scenarios

Learn more. Check out “Build a Full Stack with

React and Express”

Summary

Page 39: Daniel Stern - Mastering React Testing with Jest
Page 40: Daniel Stern - Mastering React Testing with Jest
Page 41: Daniel Stern - Mastering React Testing with Jest
Page 42: Daniel Stern - Mastering React Testing with Jest
Page 43: Daniel Stern - Mastering React Testing with Jest
Page 44: Daniel Stern - Mastering React Testing with Jest
Page 45: Daniel Stern - Mastering React Testing with Jest
Page 46: Daniel Stern - Mastering React Testing with Jest
Page 47: Daniel Stern - Mastering React Testing with Jest
Page 48: Daniel Stern - Mastering React Testing with Jest
Page 49: Daniel Stern - Mastering React Testing with Jest
Page 50: Daniel Stern - Mastering React Testing with Jest
Page 51: Daniel Stern - Mastering React Testing with Jest
Page 52: Daniel Stern - Mastering React Testing with Jest
Page 53: Daniel Stern - Mastering React Testing with Jest
Page 54: Daniel Stern - Mastering React Testing with Jest
Page 55: Daniel Stern - Mastering React Testing with Jest
Page 56: Daniel Stern - Mastering React Testing with Jest
Page 57: Daniel Stern - Mastering React Testing with Jest
Page 58: Daniel Stern - Mastering React Testing with Jest
Page 59: Daniel Stern - Mastering React Testing with Jest
Page 60: Daniel Stern - Mastering React Testing with Jest
Page 61: Daniel Stern - Mastering React Testing with Jest
Page 62: Daniel Stern - Mastering React Testing with Jest
Page 63: Daniel Stern - Mastering React Testing with Jest