Testing JS with JasmineJasmine itself and useful instruments
JavaScriptCoffeeScript
Jasmine instrumentsSuites            beforeEachSpecs             afterEachMatchers          SpiesCustom Matchers   Asynchr...
Jasmine instruments Spies             spyOn(...).andCallThrough()             spyOn(...).andReturn(arguments)Spying       ...
Jasmine Asynchronous specsruns(function)waits(timeout)waitsFor(function, optional message, optional timeout)
Jasmine minusesRuns in browser⌘+R (F5)No fixturesStatic JS vs AssetPipelineAJAX mocking isn’t friendly
Guard
GuardGuard is a command line toolto easily handle events on file modifications.  gem guard-rspec  gem guard-annotate  gem gu...
jasmine-headless-webkit
jasmine-headless-webkitIt integrates with Guard for a continuous testing setup.It compiles CoffeeScript, both for your tes...
jasmine-headless-webkitNeeds Qt (actually this is not a problem but Qt compiles a lot of time)-
jasmine-jquery
jasmine-jqueryAds JQuery specific MatchersAds FixturesAds Event Spies
jasmine-jquery MatcherstoBe selector    toContain selectortoBeChecked      toExisttoBeEmpty        toHaveAttr name, valuet...
jasmine-jquery Fixtures<div id="my-fixture">some complex content here</div>loadFixtures myfixture.html$(#my-fixture).myTested...
jasmine-jquery Event SpiesspyOnEvent $(#some_element), click$(#some_element).click()expect(click).toHaveBeenTriggeredOn $#...
jasmine-ajax
jasmine-ajax1.Defining test responses2.Installing the mock3.Defining the response for each request4.Inspecting Ajax requests...
Time for code
Linkshttps://github.com/pivotal/jasmine/wikihttp://jashkenas.github.com/coffee-script/http://johnbintz.github.com/jasmine-...
Upcoming SlideShare
Loading in...5
×

Testing JS with Jasmine

1,613

Published on

Jasmine itself and useful instruments

Published in: Technology
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,613
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
35
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Testing JS with Jasmine

    1. 1. Testing JS with JasmineJasmine itself and useful instruments
    2. 2. JavaScriptCoffeeScript
    3. 3. Jasmine instrumentsSuites beforeEachSpecs afterEachMatchers SpiesCustom Matchers Asynchronous specs
    4. 4. Jasmine instruments Spies spyOn(...).andCallThrough() spyOn(...).andReturn(arguments)Spying spyOn(...).andThrow(exception)Mocking spyOn(...).andCallFake(function)Faking callCount mostRecentCall.args argsForCall[i]
    5. 5. Jasmine Asynchronous specsruns(function)waits(timeout)waitsFor(function, optional message, optional timeout)
    6. 6. Jasmine minusesRuns in browser⌘+R (F5)No fixturesStatic JS vs AssetPipelineAJAX mocking isn’t friendly
    7. 7. Guard
    8. 8. GuardGuard is a command line toolto easily handle events on file modifications. gem guard-rspec gem guard-annotate gem guard-bundler gem guard-rails-assets gem guard-jasmine-headless-webkit
    9. 9. jasmine-headless-webkit
    10. 10. jasmine-headless-webkitIt integrates with Guard for a continuous testing setup.It compiles CoffeeScript, both for your tests and for your applicationlogic.It can be configured like RSpec, and its output is very similar to RSpecsoutput.It provides cleaner debugging and backtrace output than a lot of otherconsole-based test tools provide.Its fast.
    11. 11. jasmine-headless-webkitNeeds Qt (actually this is not a problem but Qt compiles a lot of time)-
    12. 12. jasmine-jquery
    13. 13. jasmine-jqueryAds JQuery specific MatchersAds FixturesAds Event Spies
    14. 14. jasmine-jquery MatcherstoBe selector toContain selectortoBeChecked toExisttoBeEmpty toHaveAttr name, valuetoBeHidden toHaveClass classNametoBeSelected toHandle eventNametoBeVisible etc...
    15. 15. jasmine-jquery Fixtures<div id="my-fixture">some complex content here</div>loadFixtures myfixture.html$(#my-fixture).myTestedPlugin()expect($(#my-fixture)).to...
    16. 16. jasmine-jquery Event SpiesspyOnEvent $(#some_element), click$(#some_element).click()expect(click).toHaveBeenTriggeredOn $#some_element
    17. 17. jasmine-ajax
    18. 18. jasmine-ajax1.Defining test responses2.Installing the mock3.Defining the response for each request4.Inspecting Ajax requests and setting expectations on them
    19. 19. Time for code
    20. 20. Linkshttps://github.com/pivotal/jasmine/wikihttp://jashkenas.github.com/coffee-script/http://johnbintz.github.com/jasmine-headless-webkit/https://github.com/velesin/jasmine-jqueryhttps://github.com/pivotal/jasmine-ajaxhttps://github.com/guard/guard/wiki/List-of-available-Guards
    1. A particular slide catching your eye?

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

    ×