Skip to content

Incorrect coverage for @Inject annotation in constructor parameters. #156

@wawyed

Description

@wawyed

We've had this issue for a while now and I was wondering if there's was a way to fix it. Seems like for some reason when we use @Inject the branch coverage goes down and we have to add exceptions for all this files, which is less than ideal.

image

EDIT:

Looking at the javascript I can see this lines:

__cov_NNIkqNquRPx$qWAmG6gCfg.s['37']++;
        __decorate([core_1.Input(), __metadata('design:type', (__cov_NNIkqNquRPx$qWAmG6gCfg.b['15'][0]++,
        typeof (_a = (__cov_NNIkqNquRPx$qWAmG6gCfg.b['16'][0]++,
        typeof model_form_config_1.IModelFormConfig !== 'undefined') && (__cov_NNIkqNquRPx$qWAmG6gCfg.b['16'][1]++,
        model_form_config_1.IModelFormConfig)) === 'function') && (__cov_NNIkqNquRPx$qWAmG6gCfg.b['15'][1]++,
        _a) || (__cov_NNIkqNquRPx$qWAmG6gCfg.b['15'][2]++,
        Object))], ModelFormComponent.prototype, 'mhrModelFormConfig', void 0);
        __cov_NNIkqNquRPx$qWAmG6gCfg.s['38']++;
        ModelFormComponent = __decorate([core_1.Component({
            selector: 'mhr-model-form',
            templateUrl: '/base/src/app/shared/business-components/model-form/model-form.html'
        }), __param(1, core_1.Inject('mhrModalDialog')), __metadata('design:paramtypes', [(__cov_NNIkqNquRPx$qWAmG6gCfg.b['17'][0]++,
        typeof (_b = (__cov_NNIkqNquRPx$qWAmG6gCfg.b['18'][0]++,
        typeof forms_1.MhrDynamicFormFactory !== 'undefined') && (__cov_NNIkqNquRPx$qWAmG6gCfg.b['18'][1]++,
        forms_1.MhrDynamicFormFactory)) === 'function') && (__cov_NNIkqNquRPx$qWAmG6gCfg.b['17'][1]++,
        _b) || (__cov_NNIkqNquRPx$qWAmG6gCfg.b['17'][2]++,
        Object), (__cov_NNIkqNquRPx$qWAmG6gCfg.b['19'][0]++,
        typeof (_c = (__cov_NNIkqNquRPx$qWAmG6gCfg.b['20'][0]++,
        typeof IMhrModalDialog_1.IMhrModalDialog !== 'undefined') && (__cov_NNIkqNquRPx$qWAmG6gCfg.b['20'][1]++,
        IMhrModalDialog_1.IMhrModalDialog)) === 'function') && (__cov_NNIkqNquRPx$qWAmG6gCfg.b['19'][1]++,
        _c) || (__cov_NNIkqNquRPx$qWAmG6gCfg.b['19'][2]++,
        Object)])], ModelFormComponent);
        __cov_NNIkqNquRPx$qWAmG6gCfg.s['39']++;
        exports.ModelFormComponent = ModelFormComponent;
        __cov_NNIkqNquRPx$qWAmG6gCfg.s['40']++;
        var _a, _b, _c;

I believe this lines aren't going to be covered:

        typeof IMhrModalDialog_1.IMhrModalDialog !== 'undefined') && (__cov_NNIkqNquRPx$qWAmG6gCfg.b['20'][1]++,
        IMhrModalDialog_1.IMhrModalDialog)) === 'function') && (__cov_NNIkqNquRPx$qWAmG6gCfg.b['19'][1]++,

This is the js code without coverage:

__decorate([
    core_1.Input(),
    __metadata("design:type", typeof (_a = typeof model_form_config_1.IModelFormConfig !== "undefined" && model_form_config_1.IModelFormConfig) === "function" && _a || Object)
], ModelFormComponent.prototype, "mhrModelFormConfig", void 0);
ModelFormComponent = __decorate([
    core_1.Component({
        selector: 'mhr-model-form',
        templateUrl: '/base/src/app/shared/business-components/model-form/model-form.html'
    }),
    __param(1, core_1.Inject('mhrModalDialog')),
    __metadata("design:paramtypes", [typeof (_b = typeof forms_1.MhrDynamicFormFactory !== "undefined" && forms_1.MhrDynamicFormFactory) === "function" && _b || Object, typeof (_c = typeof IMhrModalDialog_1.IMhrModalDialog !== "undefined" && IMhrModalDialog_1.IMhrModalDialog) === "function" && _c || Object])
], ModelFormComponent);
exports.ModelFormComponent = ModelFormComponent;
var _a, _b, _c;

Interesting enough when I compile my code using tsc I get this output:

__decorate([
    core_1.Input(),
    __metadata("design:type", Object)
], ModelFormComponent.prototype, "mhrModelFormConfig", void 0);
ModelFormComponent = __decorate([
    core_1.Component({
        selector: 'mhr-model-form',
        template: "<mhr-form [model]=\"dynamicForm$\" (onDelete)=\"remove()\" [mhrUnsavedChanges]=\"{ formContainer: formContainer }\"></mhr-form>"
    }),
    __param(1, core_1.Inject('mhrModalDialog')),
    __metadata("design:paramtypes", [forms_1.MhrDynamicFormFactory, Object])
], ModelFormComponent);
exports.ModelFormComponent = ModelFormComponent;

Since IMhrModalDialog is an interfaces and won't exist at run time, the question is why is that code there.

Any suggestions?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions