Pivotal Labs

Main menu

Skip to primary content
Skip to secondary content
  • About
  • Case Studies
  • Team
    • Executives
    • Locations
      • San Francisco (HQ)
      • Boston
      • Boulder
      • Denver
      • London
      • Los Angeles
      • New York
  • Community
    • Blogs
    • Tech Talks
    • Events
  • Careers
    • Lifestyle
    • Principles & Practices
    • Benefits
    • FAQ
    • Apply
  • Tools
  • Contact
    • Press Room
    • Press Releases
    • In The News
    • Press Kit
  • All
  • Labs
  • Standup
  • Tracker

Running JSHint from within Jasmine

Ben Moss
Wednesday, August 22, 2012

I often find myself wasting a lot of time debugging a mysteriously failing Jasmine spec, only to find the root cause being some missing semicolon, the accidental use of double-equals equality or some similar Javascript eccentricity hiding inside my code. On my current project we had been using JSHint through the jslint_on_rails gem to lint our Javascript as part of our test suite, but the unfortunate part of that is that it’s outside of our normal TDD cycle, functioning more like a style enforcer than something that can actually help you find bugs.

To help with getting more instant feedback, I wanted to see if we could get JSHint to run against our code from within the Jasmine test suite itself. I came across this blog post from Brandon Keepers describing how he does exactly that.

One gotcha I ran into was that I had a number of global objects defined in my specs both by Jasmine and several libraries we were using. JSHint defines some options for whitelisting common globals in its docs under “Environments”, but does a poor job of explaining how to whitelist additional variables. I discovered that by passing an object literal of globals as a third argument to the JSHINT function, I could exempt these from definition warnings.

A partial list of ones I’ve so far found handy:

var globals = {
   _: false,
   _V_: false,
   afterEach: false,
   beforeEach: false,
   confirm: false,
   context: false,
   describe: false,
   expect: false,
   it: false,
   jasmine: false,
   JSHINT: false,
   mostRecentAjaxRequest: false,
   qq: false,
   runs: false,
   spyOn: false,
   spyOnEvent: false,
   waitsFor: false,
   xdescribe: false
};
  • 0 Shares
  • Share on Facebook
  • Share on Twitter

2 Comments

  1. jane says:

    Michael Kors designer bags should be enhanced additionally cutting-edge. Your partner’s bags assortment inside the convenient stylishly presented in the happy vivid.
    For example the Metallic Leather Patchwork Carrier is really a wonderful summer handbag. Its bright colours make it perfect for partnering along with simple outfits, creating a assured additionally informal appear. Like the majority of purses by Low-priced Imitation Michael Kors Handbags, it features a strap attached. However in packing the actual bag you need to pay attention to the weight from the material due to the strap’s thickness. The Michael Kors Satchel, however, is really a larger bag. It arrives with the standard wallets lined along with precious metal edges along with a much firmer straps. The bag is available in possibly rose or dark. For a tote along with greater perform and employ, the Beverly Drawstring Satchel is a great choice. Whatever your decision, Michael Kors tote additionally handbags retain the exact same element that’s been a person’s signature – advanced, trendy additionally typically chic!

    August 23, 2012 at 12:10 am

  2. Matt says:

    while Jane makes an excellent point about designer bags, I question their relevance to this discussion.

    August 23, 2012 at 10:28 am

Add New Comment Cancel reply

Your email address will not be published.

Ben Moss

Ben Moss
New York

Recent Posts

  • Means, Ends, Mocks, Stubs
  • Debugging Travis builds
Subscribe to Ben's Feed

Author Topics

ci (1)
travis-ci (1)
javascript (1)
  • About
  • Case Studies
  • Team
  • Community
  • Careers
  • Tools
  • Contact
  • Labs
  • Events

Contact Us

contact@pivotallabs.com
+1 415-77-PIVOT
TwitterLinkedInFacebook

Pivotal Tracker

Tracker is the award-winning agile project management tool that enables real-time collaboration around a shared, prioritized backlog.
Visit pivotaltracker.com >