Slide 1

Slide 1 text

Javascript Unit Test for humans

Slide 2

Slide 2 text

Michael Lancaster @weblancaster @weblancaster Senior Interactive Developer http://www.bymichaellancaster.com/blog/client-side-javascript-unit-tests-for-front-end-developers/

Slide 3

Slide 3 text

“Program testing can be used to show the presence of bugs, but never to show their absence!” Edsger Dijkstra

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

So, why unit test at all?

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

NIST report that the relative cost to repair a defect found in an operational system is 470 to 880 times the amount to repair a defect found at the start of the life cycle when requirements are being formulated. *NIST (National Institute of Standards and Technology)

Slide 9

Slide 9 text

Productivity Security Improve code design Reduce bugs Reduce fear Usability Quality Benefits… Documentation

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

How to start?

Slide 12

Slide 12 text

Make unit tests part of the culture and processes

Slide 13

Slide 13 text

Make the process easy and people will do it

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

Automate all the things

Slide 16

Slide 16 text

Write unit test as you code (ideally before) Test before push Test in your CI

Slide 17

Slide 17 text

What tools to use?

Slide 18

Slide 18 text

http://karma-runner.github.io/0.13/index.html

Slide 19

Slide 19 text

http://mochajs.org/

Slide 20

Slide 20 text

http://chaijs.com/

Slide 21

Slide 21 text

http://sinonjs.org/ Sinon.js

Slide 22

Slide 22 text

Show me some code * https://github.com/weblancaster/karma-mocha-chai-sinon

Slide 23

Slide 23 text

Conclusion… • Make unit tests part of the culture • Make unit test processes easy • Unit test your code as you go (ideally before) • Structure unit tests in 3A (Arrange, Act, Assert) • Automate all the things

Slide 24

Slide 24 text

Thanks! http://www.bymichaellancaster.com/blog/client-side-javascript-unit-tests-for-front-end-developers/