Your SlideShare is downloading. ×
  • Like
Testing JS with Jasmine
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Now you can save presentations on your phone or tablet

Available for both IPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Testing JS with Jasmine

  • 1,505 views
Published

Jasmine itself and useful instruments

Jasmine itself and useful instruments

Published in Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
1,505
On SlideShare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
34
Comments
0
Likes
3

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n

Transcript

  • 1. Testing JS with JasmineJasmine itself and useful instruments
  • 2. JavaScriptCoffeeScript
  • 3. Jasmine instrumentsSuites beforeEachSpecs afterEachMatchers SpiesCustom Matchers Asynchronous specs
  • 4. Jasmine instruments Spies spyOn(...).andCallThrough() spyOn(...).andReturn(arguments)Spying spyOn(...).andThrow(exception)Mocking spyOn(...).andCallFake(function)Faking callCount mostRecentCall.args argsForCall[i]
  • 5. Jasmine Asynchronous specsruns(function)waits(timeout)waitsFor(function, optional message, optional timeout)
  • 6. Jasmine minusesRuns in browser⌘+R (F5)No fixturesStatic JS vs AssetPipelineAJAX mocking isn’t friendly
  • 7. Guard
  • 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. jasmine-headless-webkit
  • 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. jasmine-headless-webkitNeeds Qt (actually this is not a problem but Qt compiles a lot of time)-
  • 12. jasmine-jquery
  • 13. jasmine-jqueryAds JQuery specific MatchersAds FixturesAds Event Spies
  • 14. jasmine-jquery MatcherstoBe selector toContain selectortoBeChecked toExisttoBeEmpty toHaveAttr name, valuetoBeHidden toHaveClass classNametoBeSelected toHandle eventNametoBeVisible etc...
  • 15. jasmine-jquery Fixtures<div id="my-fixture">some complex content here</div>loadFixtures myfixture.html$(#my-fixture).myTestedPlugin()expect($(#my-fixture)).to...
  • 16. jasmine-jquery Event SpiesspyOnEvent $(#some_element), click$(#some_element).click()expect(click).toHaveBeenTriggeredOn $#some_element
  • 17. jasmine-ajax
  • 18. jasmine-ajax1.Defining test responses2.Installing the mock3.Defining the response for each request4.Inspecting Ajax requests and setting expectations on them
  • 19. Time for code
  • 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