Testing javascript
Upcoming SlideShare
Loading in...5
×
 

Testing javascript

on

  • 1,442 views

 

Statistics

Views

Total Views
1,442
Views on SlideShare
857
Embed Views
585

Actions

Likes
1
Downloads
9
Comments
0

6 Embeds 585

http://creatingcode.com 250
http://feeds.feedburner.com 203
http://robertgreiner.com 84
http://localhost 46
http://creatingcode.net 1
http://feedwrangler.net 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Testing javascript Testing javascript Presentation Transcript

  • 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?