So I have an @Input form: FormGroup.
Unit Testing
describe('Component', () => {
let component: Component;
let fixture: ComponentFixture<Component>;
let apiService: ApiService;
let fb: FormBuilder = new FormBuilder();
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [Component, TranslatePipeMock],
imports: [ReactiveFormsModule, FormsModule],
providers: [
ChangeDetectorRef,
{ provide: FormBuilder, useValue: fb },
{
provide: ApiService,
useValue: apiServiceStub,
},
{
provide: TranslateService,
userValue: translateServiceStub,
},
],
schemas: [NO_ERRORS_SCHEMA],
}).compileComponents();
});
beforeEach(() => {
apiLookupService = TestBed.inject(ApiLookupService);
fixture = TestBed.createComponent(InputWhtComponent);
fb = TestBed.inject(FormBuilder);
component = fixture.componentInstance;
const expectedForm = fb.group({
isWithholdingTaxEnabled: new FormControl(true),
});
component.form = expectedForm;
fixture.detectChanges();
});
But i am having this error right now, No value accessor for form control with name: 'isWithholdingTaxEnabled'