0

I'm sorry if this is a rather ambiguous question -- I used to be one of those devs who is far too lazy to write unit tests, but now that I'm working on a pretty large project, I've come to see the value in them.

I've set up istanbul with some (hopefully) sensible thresholds:

const options = {
    codeCoverage: {
        reporters: ['lcov', 'text-summary'],
        thresholds: {
            global: { statements: 80, branches: 80, functions: 80, lines: 80 },
            each: { statements: 50, branches: 50, functions: 50, lines: 50 }
        }
    }
};

But this causes my test task in gulp to fail, because istanbul reports that my config files (those that set up middleware and various other boilerplate-ish stuff) aren't covered.

I've tried searching for hours, but haven't found any guidelines as to which code is safe to ignore -- I've only been told by more senior developers that it's necessary to test controllers and so on, but not config files -- which are pretty much impossible to test anyway. Feedback would be much appreciated!

natnai
  • 554
  • 2
  • 10
  • Is this what you're looking for? https://github.com/gotwarlost/istanbul#ignoring-code-for-coverage. I realise you're asking if it's safe to ignore. I'd say it is as long as you're config readers are covered. – Lars de Bruijn May 03 '16 at 11:16
  • Thanks for the answer. I know _how_ to ignore the code, but not whether it's safe to or not. Take for example lambdas passed into `app.use()` -- some of them are so dead simple I don't see the value in testing them. It would just be a waste of time. – natnai May 03 '16 at 11:23

0 Answers0