Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Testing javascript

2,138 views

Published on

Published in: Technology
  • Be the first to comment

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?

×