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”
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().
Too fast explanation.
How do you get a html test run report?
A channel called "Best of the Best" uploaded this video homie
How do you setup all these files?
a bloody duck, haha
This guy is funny.
I belive you can use ctrl+f5 to delete the cach in the current page. try it
"Well I'm not that lucky; I don't live in Brooklyn." I got a good laugh out of that one
Hi Jesse, thanks a lot, it is a really good video about jasmine!
Great intro to Jasmine and JS unit testing. It is easy to understand. Thanks Jesse.
"Coopling"? Come on…
very nice, thanks
Excellent video, i was exactly looking for something like this. You have shown the real example and not just using a Calculator. Thanks for sharing
Hey Jesse Warden, How are you? Long time no see!! I like the video a lot. I hope you are doing well at Barclays.
Great video!, after this quick video, I am certain I am ready to start testing my code for the company I work for, so I know everything will be production ready!
Take a look at ZombieJS, may be what you're looking for.
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
:: holds up cardboard sign :: "wIll cUdDlE BrAKeTz 4 MuNey"
RABBLE RABBLE RABBLE! You're putting braces on a new line! RABBLE RABBLE RABBLE!
Thanks a bunch for this btw. Very useful
Umm, doesn't Cmd+Shift+R let you refresh the test runner
page by skipping the browser cache? You could simply use
that to force refresh instead of clearing the cache so many
times.
I absolutely love your side comments. Shows us programmers are not just robots.
Very concise, great information, well spoken, easy to understand, quality recording.
subscriber++;
Thank you for first 4 minutes.
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
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.
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!
I see you're using WebStorm. Did you try to use JSTestDriver Plugin to run Jasmine tests inside IDE?