Glad You're Ready. Let's Get Started!

Let us know how we can contact you.

Thank you!

We'll respond shortly.

  • Blog Navigation
Running JSHint from within Jasmine

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
  • 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!

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

  • The predefined globals can simply be added to the .jshintrc file under the “predef” option. For example:
    “bitwise”: true,
    “camelcase”: true,
    “curly”: true,
    “immed”: true,
    “latedef”: true,
    “newcap”: true,
    “noarg”: true,
    “noempty”: true,
    “quotmark”: “single”,
    “undef”: true,
    “unused”: true,
    “strict”: true,
    “debug”: true,
    “evil”: false,
    “node”: true,
    “predef”: [

Share This