Getting Started with Intern

Intern is a full-featured JavaScript test framework developed by the fine folks at SitePen. While there are other excellent options out there (most notably Mocha[53]), Intern stands out as a natural choice for testing CoffeeScript because it includes full support for source maps.

Before we begin, make a copy of the project from the previous chapter in a new directory. Now let’s install Intern as a development dependency and add a tests directory:

 $ ​​npm​​ ​​install​​ ​​--save-dev​​ ​​intern
 $ ​​mkdir​​ ​​tests

Intern doesn’t have out-of-the-box support for CoffeeScript, so we’ll be compiling our test files with Grunt. To accommodate that, let’s subdivide tests:

 $ ​​mkdir​​ ​​tests/src
 $ ​​mkdir​​ ​​

Get CoffeeScript, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.