First thing:
I still don't really get the meaning of coverage. Please can somebody explain it to me as if I was a child ?
Does it means: any request/handler/response not tested ? Does it means: any function or even any instruction not tested ?
I have a small case. I am doing an API as a plugin, and I want the plugin to hold its lab package and test directory, so its tests don't care about the rest of the world. I was just trying to check that everything is setup correctly so I can start writing my actual tests, so I just created a test directory in my plugin root, and I put the below test inside:
const Code = require('code');
const Lab = require('lab');
const lab = Lab.script();
exports.lab = lab;
const expect = Code.expect;
lab.test('returns true when 1 + 1 equals 2', (done) => {
expect(1 + 1).to.equals(2);
done();
});
But when I run lab, I get: 0% coverage, 0 SLOC (0 Covered, 0 Not Covered).
I am just confuse. Please can somebody tell me what I am doing wrong, or what I am not understanding.
Thank you in advance.
Second thing:
To make it short, please can somebody provide a sample .labrc.js file, with most of the options set the right way, including --coverage-path and --coverage-exclude
In your example your are not testing a unit of code your are just running a local assertion. Here is an example of some hapi plugin's tests I have written. Coverage relates to the the lines of code you are covering by writing your tests. Personally I have never used the .labrc.js file as you can configure npm init to reproduce your tests command.