2020-05-07 10:54:55 +00:00
|
|
|
const { describe, it } = require('mocha');
|
2022-02-09 14:49:25 +00:00
|
|
|
const { getCoverageResults } = require('./coverage-utils.js');
|
2020-04-30 12:00:41 +00:00
|
|
|
const expect = require('expect');
|
|
|
|
|
|
|
|
describe('API coverage test', () => {
|
|
|
|
it('calls every method', () => {
|
|
|
|
if (!process.env.COVERAGE) return;
|
|
|
|
|
|
|
|
const coverageMap = getCoverageResults();
|
|
|
|
const missingMethods = [];
|
|
|
|
for (const method of coverageMap.keys()) {
|
2020-05-07 10:54:55 +00:00
|
|
|
if (!coverageMap.get(method)) missingMethods.push(method);
|
2020-04-30 12:00:41 +00:00
|
|
|
}
|
|
|
|
if (missingMethods.length) {
|
2020-05-07 10:54:55 +00:00
|
|
|
console.error(
|
|
|
|
'\nCoverage check failed: not all API methods called. See above output for list of missing methods.'
|
|
|
|
);
|
2020-04-30 12:00:41 +00:00
|
|
|
console.error(missingMethods.join('\n'));
|
|
|
|
}
|
|
|
|
|
|
|
|
// We know this will fail because we checked above
|
|
|
|
// but we need the actual test to fail.
|
|
|
|
expect(missingMethods.length).toEqual(0);
|
|
|
|
});
|
|
|
|
});
|