!SLIDE

Tea Time

A Beginner's Guide to JavaScript Testing using Jasmine

By John Bintz

!SLIDE # Automated testing is important !SLIDE # Why is it important? !SLIDE image-80-percent !SLIDE # Fortunately, we're beyond that nowadays !SLIDE larger ``` ruby require 'spec_helper' describe MyCoolWebsite do let(:website) { described_class.new } describe '#cool_method' do subject { website.cool_method } let(:oh_yeah) { [ double_cool ] } let(:double_cool) { 'double cool' } before do website.stubs(:whoa_cool).returns(oh_yeah) end it { should == double_cool } end end ``` !SLIDE # But there's more to web apps than Ruby nowadays... !SLIDE even-larger ``` html ``` !SLIDE larger ``` html ``` !SLIDE # jQuery !SLIDE # Backbone !SLIDE # Sprockets and RequireJS !SLIDE # Automated testing is important !SLIDE larger ``` ruby require 'spec_helper' describe MyCoolWebsite do let(:website) { described_class.new } describe '#cool_method' do subject { website.cool_method } let(:oh_yeah) { [ double_cool ] } let(:double_cool) { 'double cool' } before do website.stubs(:whoa_cool).returns(oh_yeah) end it { should == double_cool } end end ``` !SLIDE larger ``` coffeescript describe 'MyCoolWebsiteView', -> website = null beforeEach -> website = new MyCoolWebsiteView() describe '#coolMethod', -> doubleCool = 'double cool' ohYeah = [ doubleCool ] beforeEach -> website.whoaCool = -> ohYeah it 'should be double cool', -> expect(website.coolMethod()).toEqual(doubleCool) ``` !SLIDE # Jasmine !SLIDE # BDD unit testing framework for JavaScript !SLIDE # Platform independent !SLIDE # Easily extended !SLIDE # Very easy to learn!