Error: No value accessor for form control with unspecified name attribute in Jasmine and karma...

Discussão em 'Angular' iniciado por Jennifer Yasmin, Outubro 29, 2024.

  1. I'm having this message in 20 of my tests that worked perfectly before:

    Error: No value accessor for form control with unspecified name attribute


    All test are failing with angular, jasmine and karma.

    What I did before running the tests again was changing one function to another: Old function:

    public isDisabledDQReviewer(): boolean {
    const periodicity = this.typeSettingForm.get('periodicity').value;
    const isDaily = periodicity === 'Diaria';
    const isDisabled = !this.isRoleGMRU || isDaily;


    if (isDaily) {
    this.typeSettingForm.get('reviewer').setValue(false);
    }


    return isDisabled;
    }



    New function:

    public checkDQReviewerStatus(): void {
    const periodicity = this.typeSettingForm.get('periodicity').value;
    const isDaily = periodicity === 'Diaria';
    const isMonthly = periodicity === 'Mensual';

    const isDisabled = !this.isRoleGMRU || isDaily;

    if (isDaily) {
    this.typeSettingForm.get('reviewer').setValue(false);
    }

    if (isDisabled) {
    this.typeSettingForm.get('reviewer').disable({ emitEvent: false });
    } else {
    this.typeSettingForm.get('reviewer').enable({ emitEvent: false });
    }
    if (isMonthly && this.isRoleGMRU) {
    this.typeSettingForm.get('reviewer').enable();
    }
    }


    All testing according to this component are failing, even though they don't include this function. These are some examples:

    it('is defined', () => {
    expect(testing.component).toBeDefined();
    });

    it('should disable reviewer if role is not GMRU', () => {
    testing.component.typeSettingForm.get('periodicity').setValue('Diaria');


    const result = testing.component.checkDQReviewerStatus();


    expect(result).toBeTruthy();
    expect(testing.component.typeSettingForm.get('reviewer').value).toBe(false);
    });


    I changed the name of the function in every test and I try to redo them, but nothing seems to work.

    I need those tests to run correctly.

    Continue reading...

Compartilhe esta Página