Skip to Content
JavaScript Testing with Jasmine
book

JavaScript Testing with Jasmine

by Evan Hahn
March 2013
Intermediate to advanced
52 pages
51m
English
O'Reilly Media, Inc.
Content preview from JavaScript Testing with Jasmine

Chapter 7. Using Jasmine with Other Tools

I’ve demonstrated how to run Jasmine using JavaScript in the browser, but you don’t have to do it that way. Jasmine works in a variety of other environments and with other tools.

Jasmine and CoffeeScript

CoffeeScript is a language that compiles to JavaScript, and it’s beautiful. It makes coding in JavaScript much easier, and it also makes your Jasmine code look better. Using CoffeeScript with Jasmine is a fairly straightforward process, and your specs will look pretty.

If you don’t already use CoffeeScript, I’d strongly recommend it. It’s easy to learn if you know JavaScript, and it reduces a lot of the headaches that come with JavaScript. There are some people who don’t like CoffeeScript, though—it’s up to you whether to use it or not.

If you want to give CoffeeScript a try, you can test it out at CoffeesScript.org, where you’ll also find installation instructions and documentation. If you have npm installed, you can install CoffeeScript like so:

  sudo npm install -g coffee-script

If you don’t have npm or want to use CoffeeScript in a different way, check the CoffeeScript website for more usage instructions.

One of the things that makes Jasmine specs look nice in CoffeeScript is the language’s optional parentheses. The following two lines are equivalent in CoffeeScript:

  alert("Hello world!")
  alert "Hello world!"

Because Jasmine’s describe and it are just functions, you can write nice-looking specs that don’t have as many brackets and parentheses. ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Jasmine JavaScript Testing Update

Jasmine JavaScript Testing Update

Paulo Vitor Zacharias Ragonha
Testing Angular Applications

Testing Angular Applications

Corinna Cohn, Corinna Coen, Michael Giambalvo, Craig Nishina, Jesse Palmer

Publisher Resources

ISBN: 9781449356729Errata Page