Стамбул / Нью-Йорк c не обнаруживает код во время покрытия кода - PullRequest
0 голосов
/ 29 мая 2020

ny c не распространяется на следующий код

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
require("mocha");
require("./core");
describe('Core Import', () => {
    it('just import core file for code coverage', () => {
        console.log('Ok!');
    });
});

Как видите, покрытие кода составляет 0%

enter image description here

Однако, объявляя одну переменную внутри describe, код покрывается

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
require("mocha");
require("./core");
describe('Core Import', () => {
    const ans = []; // I added this
    it('just import core file for code coverage', () => {
        console.log('Ok!');
    });
});

Теперь это 100%

enter image description here

Почему это поведение такое? Есть что-нибудь с моей конфигурацией?

{
  "reporter": [
    "text",
    "html"
  ],
  "all": true,
  "sourceMap": true,
  "instrument": true
}

Я запускаю тесты с:

nyc mocha build/**/*.spec.js --recursive --timeout 20000 -r source-map-support/register
...