Unit Testing in JavaScript via Jasmine

  Рет қаралды 105,525

Jesse Warden

Jesse Warden

Күн бұрын

Пікірлер: 68
@koundamanee
@koundamanee 9 жыл бұрын
Great intro to Jasmine and JS unit testing. It is easy to understand. Thanks Jesse.
@xxgadirxx1010
@xxgadirxx1010 6 жыл бұрын
Well done! It's easy to follow and packed with good information. I am adding Jasmine to a new project and I needed a refresher.
@JesseWarden
@JesseWarden 12 жыл бұрын
Yeah, we're actually working on that with Maven & Jenkins. We already have FlexUnit running our test suites for our ActionScript via mxmlc. For this, I believe you have Maven/ANT run your Jasmine suite using PhantomJS (a headless WebKit browser). You can also use ZombieJS for handling global objects in case your code is too hard to refactor or just requires they exist. One of these days I'll do a screen cast on it.
@JesseWarden
@JesseWarden 12 жыл бұрын
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.
@aniketsamudra1374
@aniketsamudra1374 10 жыл бұрын
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
@GlenBeebe
@GlenBeebe 9 жыл бұрын
"Well I'm not that lucky; I don't live in Brooklyn." I got a good laugh out of that one
@DavidSandersT
@DavidSandersT 12 жыл бұрын
Very concise, great information, well spoken, easy to understand, quality recording. subscriber++;
@lifeofcoding
@lifeofcoding 11 жыл бұрын
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!
@James_D_Bartlett_III
@James_D_Bartlett_III 6 жыл бұрын
Hey, Jesse! Love your videos, man. Definitely a great resource for newbies like me. Any chance you'll make an update of this video using the current Jasmine syntax? I'm trying to follow along with the steps in this video, but it seems the Jasmine team has changed a lot under the hood since this was filmed.
@JesseWarden
@JesseWarden 6 жыл бұрын
I'm mostly a Mocha man nowadays. I know of ton of the Angular devs use Jasmine, though, so it still is going strong. The syntax, though, isn't that different. Both have describe. Both have it. Jasmine has like xit to skip, Mocha has it.skip. Jasmine has fit to run only 1 test. Mocha it.only. Same for xdescribe/describe.only, etc. If you're new, I'd lower the amount of stuff you have to learn and take Eric Elliot's advice, and just focus on 1 assertion. The biggest issue with learning new things is: 1. memorizing new syntax 2. learning how it works Unit testing is hard, too because it includes a ton of new things, like writing testable code, consuming your own API, refactoring based on how it tastes after you've consumed it, abstraction, stubbing, mocking, spies, setup, tearndown, coverage, blah blah blah. We can reduce #1 by just focusing on true and false. What Jasmine calls Matchers, Mocha calls Assertions (usually through the Chai library). Both Jasmine and Mocha have a lot of assertions. ... don't use 'em for now. Just focus on true or false. const result = someFunction(stub) // Jasmine expect(result).toBe(true) // Mocha expect(result).to.equal(true) Obviously not every result will be true or false, so make it so. const someBigObject = someFunction(stub) const looksCorrect = someBigObject.firstName === "James" expect(looksCorrect).toBe(true) That kind of thing. That way, you have a ton of tests that just assert true or false, easier to follow, less to learn. Memorizing everything on this page jasmine.github.io/api/edge/matchers.html is ree-dic. I google Jasmine/Mocha assertions all the time, man, and I've been at this for 4 years in both frameworks.
@James_D_Bartlett_III
@James_D_Bartlett_III 6 жыл бұрын
Jesse Warden Wow, that was a great answer! Thanks for the suggestions. I'm honestly only using Jasmine right now because the course I'm taking on Udacity uses it. I'm not sure what framework I would use if I had to choose one on my own. But considering that I have only been writing Javascript for less than a year, I think it's probably OK if I remain agnostic on that question for a little while. I'm still wrapping my head around the language itself. Thanks again for taking the time to explain those differences and pointing out the importance of sticking to the simplest tests for now. That will definitely help me going forward. Cheers!
@JesseWarden
@JesseWarden 6 жыл бұрын
No stress. You can't really make a wrong choice. Most developers don't write unit tests so you're already studying elite stuff and head of the curve.
@James_D_Bartlett_III
@James_D_Bartlett_III 6 жыл бұрын
Jesse Warden That's the best news I've heard all year. Right now it feels like I'm drowning in new information, and like I'm barely even keeping up, so to hear it from a pro that I'm ahead of the curve is such a relief. Thanks again, man. I'm definitely subscribing to your channel and telling my fellow students to do the same.
@JesseWarden
@JesseWarden 6 жыл бұрын
"drowning in new information, and like I'm barely even keeping up"
@JesseWarden
@JesseWarden 12 жыл бұрын
1. It doesn't work unless the Debug Console is open. 2. The Debug Console does not open by default, so you have to manually open it; this is painful for when you refresh from Sublime or WebStorm/IntelliJ and they open a new tab. It only works per tab, not the entire browser.
@KiranIgnatius
@KiranIgnatius 11 жыл бұрын
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
@dazld1
@dazld1 12 жыл бұрын
jesse, you can set an option in chrome's console to disable the cache, you know ;)
@makayud
@makayud 9 жыл бұрын
Hi Jesse, thanks a lot, it is a really good video about jasmine!
@whosmav628
@whosmav628 7 жыл бұрын
A channel called "Best of the Best" uploaded this video homie
@DrrtyEnt
@DrrtyEnt 9 жыл бұрын
sounds like Frink the nerd from simpson.. nice video man.. unit tests are great
@JesseWarden
@JesseWarden 12 жыл бұрын
New Video: Unit Testing in JavaScript via Jasmine Unit Testing in JavaScript via Jasmine
@sanddemon123
@sanddemon123 12 жыл бұрын
Two things not necessarily related to unit-testing....how ya like WebStorm? And what'd you use to record this...
@JesseWarden
@JesseWarden 12 жыл бұрын
Getting into WebStorm was tough. I've always been a massive fan of IntelliJ, but never liked how slow it was compared to TextMate/Sublime. For JavaScript, it was worse because you tend to fly around different files faster. ...however, after I turned on every single inspection, and used the code formatting, I started noticing my code have less bugs. The colors that show un-used variables, the red indicating mispellings or lack of scope; that kind of stuff. It really helps compensate for the lack of a compiler, and has reasonable refactoring support... sometimes, for JavaScript. I'll still use Sublime for searches since it's less strict than WebStorm is, but I like the formatting and code error indications that WebStorm has. Took me a week to get used to it and fully transfer over. Extremely disappointed with the unit test support; jsTestDriver just does not work as advertised. Me and another dude had the same problem, although, you can theoretically edit the file it generates. Regardless, Jasmine is what we've chosen as our unit test library and there is no turning back now, so it'd be nice to figure that integration out.
@JesseWarden
@JesseWarden 12 жыл бұрын
For screen recording, ScreenFlow. Best money spent next to BeyondCompare and Crossover.
@YakovFain
@YakovFain 12 жыл бұрын
Nice screen cast, Jesse Warden. You can disable cache in Chrome. Click on the image of a little wrench at the top right corner of the browser’s window, and select Tools | Developer tools. Then click on the little round Settings icon at the right bottom corner of the page. It’ll open a new panel, where you can easily find the Disable cache option.
@JesseWarden
@JesseWarden 12 жыл бұрын
Thanks chief!
@sutthiphong88
@sutthiphong88 10 жыл бұрын
Hey Jesse Warden, How are you? Long time no see!! I like the video a lot. I hope you are doing well at Barclays.
@JesseWarden
@JesseWarden 10 жыл бұрын
Hey sup man! Thanks. Yeah, in London currently for them, fixin' to fly to Glasgow to the other office. I haven't slept in days. Hope your well!
@JesseWarden
@JesseWarden 11 жыл бұрын
Take a look at ZombieJS, may be what you're looking for.
@ioanb
@ioanb 12 жыл бұрын
Thank you for first 4 minutes.
@wcdeich4
@wcdeich4 8 жыл бұрын
How do you setup all these files?
@JesseWarden
@JesseWarden 8 жыл бұрын
Go to this Github and either checkout, or just download the files; should give you a head start: github.com/JesterXL/JavaScript-Jasmine-Unit-Test-Example
@JesseWarden
@JesseWarden 11 жыл бұрын
:: holds up cardboard sign :: "wIll cUdDlE BrAKeTz 4 MuNey"
@wjrasmussen666
@wjrasmussen666 7 жыл бұрын
How do you get a html test run report?
@JesseWarden
@JesseWarden 7 жыл бұрын
Most of that is built into Jasmine / Mocha. If you run with their default Karma setup, you'll get an html report. However, the better report is a coverage report as it shows what you've tested vs. what you haven't.
@im1dermike
@im1dermike 9 жыл бұрын
"Coopling"? Come on...
@JesseWarden
@JesseWarden 9 жыл бұрын
im1dermike Either it's the southern accent, or I was having a stroke.
@edonis2787
@edonis2787 6 жыл бұрын
Beat me to it 😂😂😂
@SoeaOu
@SoeaOu 10 жыл бұрын
very nice, thanks
@alamandrax
@alamandrax 11 жыл бұрын
RABBLE RABBLE RABBLE! You're putting braces on a new line! RABBLE RABBLE RABBLE! Thanks a bunch for this btw. Very useful
@praveenchukka
@praveenchukka 8 жыл бұрын
This guy is funny.
@mitlandir5761
@mitlandir5761 6 жыл бұрын
The tutorial would have been way better if you actually typed the code during the tutorial, rather than just going over it. Nothing personal, maybe some people prefer it that way, but it's my honest opinion that the tutorial isn't very useful for someone who is getting started with Unit Tests in JS.
@JesseWarden
@JesseWarden 6 жыл бұрын
Agreed. I made new ones where I do: kzbin.info/www/bejne/fJDCk2epnsufjKs
@mario1ua
@mario1ua 8 жыл бұрын
a bloody duck, haha
@abh681
@abh681 6 жыл бұрын
Please talk to the point
@अलकामिश्रा
@अलकामिश्रा 7 жыл бұрын
Too fast explanation.
@JesseWarden
@JesseWarden 7 жыл бұрын
1. click gear on bottom right 2. click speed 3. choose 0.25
@अलकामिश्रा
@अलकामिश्रा 7 жыл бұрын
thanks for that :P
Derek Stobbe: Testing Angular using Karma and Jasmine
44:22
AngularJS Utah
Рет қаралды 33 М.
黑天使被操控了#short #angel #clown
00:40
Super Beauty team
Рет қаралды 61 МЛН
Сестра обхитрила!
00:17
Victoria Portfolio
Рет қаралды 958 М.
Cheerleader Transformation That Left Everyone Speechless! #shorts
00:27
Fabiosa Best Lifehacks
Рет қаралды 16 МЛН
黑天使只对C罗有感觉#short #angel #clown
00:39
Super Beauty team
Рет қаралды 36 МЛН
JS Unit Testing
55:38
LinkedInTechTalks
Рет қаралды 17 М.
Rust for TypeScript devs : Borrow Checker
8:49
ThePrimeagen
Рет қаралды 233 М.
How OnlyFans Grew Its Revenue by 2000% in Just Four Years | WSJ The Economics Of
10:11
Introduction To Karma
35:22
Jesse Warden
Рет қаралды 36 М.
AngularJS Fundamentals In 60-ish Minutes
1:10:50
Dan Wahlin
Рет қаралды 1,9 МЛН
GTAC 2013: Karma - Test Runner for JavaScript
15:34
Google TechTalks
Рет қаралды 49 М.
黑天使被操控了#short #angel #clown
00:40
Super Beauty team
Рет қаралды 61 МЛН