Unit Testing in JavaScript via Jasmine




I show you how to write unit tests in JavaScript using the Jasmine library and test runner. I’ve written classes or “modules” that work inside of Require.js and the code is in Github:

Code:

https://github.com/JesterXL/JavaScript-Jasmine-Unit-Test-Example

Follow me on Twitter and Google+

https://plus.google.com/109537902154361720350

Original source


28 responses to “Unit Testing in JavaScript via Jasmine”

  1. Being new to Jasmine, I'm reluctant to critique, but based on the Jasmine documentation, the terms "suite" and "spec" are not equivalent in the way Jesse describes: a suite is a set of tests, and a spec is a single test. Suites use describe(), and specs use it().

  2. Hey Jesse, Wonderful video

    I have a Javascript Project built with Pure mvc framework, and coffescript
    And Automated with Ant Script for Building the Project,

    How do i unit test without viewing it on a browser???
    any other way, coz i have so many pages wit different functionality

  3. Nice thing about sinonjs is you can use it with jasmine qunit mocha whatever …I've had to mock with phpunit and mockito recently (php and java) and I have to say sinonjs has spoiled me! Ok nuff pimpin sinon lolz

  4. Thanks Rob, there's are so many javascript testing libraries I've yet to try. I've heard good things about both sinon.js and mocha.js so you make 3! That's always a good sign on something worthy to try.

  5. Nice video … we use sinon.js for test doubles along with jasmine and it's working pretty nice. I've lately been getting back to use mocha.js which I actually think I prefer (although the syntax is fairly similar). Anyway, nice vid!

Leave a Reply