Need a way to inspect node.js / Mocha code for ".only" before checking into VCS/Git

We have a lot of unit and integration tests in our node.js codebase.  

When adding/updating our code it's convenient to run just our NEW tests, rather than all of them.  Mocha makes this easy, by adding ".only" to the test/describe that you want to run.  For example, we'll have this:

it.only('should get an index of event moments', function(done) {

...


However, myself and just about all the other developers continuously and accidentally check in this code to Git.  When it's merged to master, then only that one test will run for everyone.  That defeats the purpose of having all the tests! This happens often enough that we really want to do something about it.

It seems like it would be great to have a code inpector that will warn you when you check in code which searches for a regex like "/.*\.only(/i", or some similar technique.

I've look at the webstorm/phpstorm docs but I can't see any easy way to add such a feature.

Anyone have any ideas?

JB
2 comments
Comment actions Permalink

Hi there,

You cannot add your own inspection just like that AFAIK -- it needs to be coded as plugin.

The only idea that I have is:

Commit screen has "Before commit" section, which has 2 interesting options:

  1. "Check TODO". It's easy -- define your own TODO pattern (more catchy icon for easier recognition etc) and you will be able to spot them before committing. Not ideal .. but at least something that can work within a minute. This one is also good because you can see all of them in TODO panel at any time (no additional run of heavy code inspection etc -- TODOs are always actual).
  2. "Perform code analysis". If it would be PHP code, you could create your own CodeSniffer rules .. but I do not know if you can do something like that with JSLint/JSHint or similar already supported tools -- if they applicable to node.js code at all -- sorry, I'm not a JS guy)

0
Comment actions Permalink

Thanks Andriy, I'll read up on those options.  I just didn't want to miss something obvious.

0

Please sign in to leave a comment.