Testing javascript

1,514
-1

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,514
On Slideshare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
10
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Testing javascript

  1. 1. Testing JavaScript with Jasmine
  2. 2. Why should we test JavaScript?
  3. 3. How many times have youchanged something in JavaScript
  4. 4. Only to break something else?
  5. 5. JavaScript = Production Code!
  6. 6. Which means, we need to treat it with respect
  7. 7. And, preserve the ability to
  8. 8. change
  9. 9. fix
  10. 10. clean
  11. 11. and refactor our JavaScript code
  12. 12. Without fear of breaking something
  13. 13. Testing is especially important when external factors can affect how our code functions
  14. 14. What makes a good test?
  15. 15. Think F.I.R.S.T
  16. 16. Fast
  17. 17. IndependentTests should not depend on each other.
  18. 18. RepeatableAlways the same results, regardless of environment.
  19. 19. Self-Validating Pass or FailNo manual evalutation.
  20. 20. TimelyWrite tests before production code.
  21. 21. Let’s look at an example.A random function for rolling a die.
  22. 22. What’s wrong here?
  23. 23. How do we normally debug JavaScript?
  24. 24. Let’s forget we even mentioned that…
  25. 25. So… we have this buggy code.
  26. 26. What do we do about it?
  27. 27. Write a failing test
  28. 28. Then Run the test to see it fail
  29. 29. SpecRunner.html
  30. 30. Squash the bug
  31. 31. Success!
  32. 32. Add more tests
  33. 33. Win!Testing = Documentation!
  34. 34. Remember…
  35. 35. When you find yourself wanting to do this.
  36. 36. Write a test instead!
  37. 37. Questions?

×