Testing JavaScript    with Jasmine
Why should we test JavaScript?
How many times have youchanged something in JavaScript
Only to break something else?
JavaScript = Production Code!
Which means, we need to treat it        with respect
And, preserve the ability to
change
fix
clean
and refactor our JavaScript code
Without fear of breaking      something
Testing is especially important when external factors can affect how our            code functions
What makes a good test?
Think F.I.R.S.T
Fast
IndependentTests should not depend on each              other.
RepeatableAlways the same results, regardless         of environment.
Self-Validating     Pass or FailNo manual evalutation.
TimelyWrite tests before production code.
Let’s look at an example.A random function for rolling a die.
What’s wrong here?
How do we normally debug       JavaScript?
Let’s forget we even mentioned              that…
So… we have this buggy code.
What do we do about it?
Write a failing test
Then Run the test to see it fail
SpecRunner.html
Squash the bug
Success!
Add more tests
Win!Testing = Documentation!
Remember…
When you find yourself wanting         to do this.
Write a test instead!
Questions?
Testing javascript
Upcoming SlideShare
Loading in...5
×

Testing javascript

1,397

Published on

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

No Downloads
Views
Total Views
1,397
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?
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×