• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Testing Javascript with Jasmine
 

Testing Javascript with Jasmine

on

  • 3,208 views

Presentation about testing Javascript with Jasmine. https://github.com/pivotal/jasmine

Presentation about testing Javascript with Jasmine. https://github.com/pivotal/jasmine

Statistics

Views

Total Views
3,208
Views on SlideShare
3,207
Embed Views
1

Actions

Likes
8
Downloads
0
Comments
0

1 Embed 1

http://www.linkedin.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

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 with Jasmine Testing Javascript with Jasmine Presentation Transcript

    • André Faria Gomes @andrefaria
    • Jasmine is a behavior-drivendevelopment framework for testing your JavaScript code.
    • It does not depend on any other JavaScript frameworks
    • It does not require a DOM
    • It has a clean, obvious syntax so that you can easily write tests.
    • Specs
    • Expectations
    • Suites
    • Nested
    • Disabling describe => xdescribe it => xit
    • Matchers expect(x).toEqual(y); expect(x).toBe(y); //same expect(x).toMatch(pattern); //regex expect(x).toBeDefined(); //not undefined expect(x).toBeNull(); expect(x).toBeTruthy(); expect(x).toBeFalsy(); expect(x).toContain(y); //for arrays or strings expect(x).toBeLessThan(y); expect(x).toBeGreaterThan(y); expect(fn).toThrow(e); expect(x).not.toEqual(y);
    • Your Matchers
    • Before & After
    • Spies Spies are automatically removed after each spec. They may be set in the beforeEach function
    • Spying Static Methods
    • Spying Instance Methods
    • Spying CallBacks
    • Spying AJAX
    • Spying Matchersexpect(x).toHaveBeenCalled()expect(x).toHaveBeenCalledWith(arguments)expect(x).not.toHaveBeenCalled()expect(x).not.toHaveBeenCalledWith(arguments)spyOn(x, method).andCallThrough(): spies on AND calls the original function spied onspyOn(x, method).andReturn(arguments): returns passed arguments when spy is calledspyOn(x, method).andThrow(exception): throws passed exception when spy is calledspyOn(x, method).andCallFake(function): calls passed function when spy is calledSpy PropertiescallCount: returns number of times spy was calledmostRecentCall.args: returns argument array from last call to spy.argsForCall[i] returns arguments array for call i to spy.
    • Asynchronous Specs runs
    • Asynchronous Specs waiting
    • Asynchronous Specs waiting condiction
    • HTML /srcSpecRunner.html /spec
    • RubyGem
    • NodeJSpackage npm install jasmine-node --global jasmine-node scripts
    • Javamaven
    • Referenceshttps://github.com/pivotal/jasmine