1

I'm trying to test a component that has imported 'FormGroup' and 'FormBuilder', but when I'm trying to run the test file for that component it gives me an error saying 'FormGroup' and 'FormBuilder' isn't a known property of form. I tried doing something like this,

TestBed.configureTestingModule({
imports: [ ],
declarations: [ FormComponent ],
providers: [ FormGroup, FormBuilder ]
})

but then it gives the following error:

Uncaught Failed: Can't resolve all parameters for FormGroup: (?, ?, ?).
Error: Can't resolve all parameters for FormGroup: (?, ?, ?).

So how can I import formgroup and formbuilder in the testing (spec) file?

Angular Version I'm using: 2.1.0

1 Answer 1

2

it gives me an error saying 'FormGroup' and 'FormBuilder' isn't a known property of form.

The same way you imported ReactiveFormsModule into your application module(s), you need to do the same in the testing module

TestBed.configureTestingModule({
  imports: [ ReactiveFormsModule ],
  declarations: [ FormComponent ]
})
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.