title: Angular test case returns TypeError: _this.reCaptchaApi.render is not a function
body: <p>I have implemented the ngx-captcha in Angular 6 Reactive Forms. The functionality is working fine for me but when I run the unit test case, the test case fails with the following message:</p>
  
  <blockquote>
    <p>TypeError: _this.reCaptchaApi.render is not a function.</p>
  </blockquote>
  
  <p>I implemented the ngx-captcha (visible type) in two components. For both the component functionality is working fine for me, but during unit test case run I am getting the above mentioned error.</p>
  
  <p>I tried with the following:</p>
  
  <p>captcha-test.html</p>
  
  <pre><code>&lt;ngx-recaptcha2 #captchaElem [siteKey]="captchaSiteKey" 
  formControlName="captcha"&gt; &lt;/ngx-recaptcha2&gt;
  </code></pre>
  
  <p>captca-test.ts</p>
  
  <pre><code>export class CaptchaTestComponent implements OnInit {
    validSiteKey: string = environment.validSiteKey;
    captchaExampleForm: FormGroup;
    constructor(private fb: FormBuilder) { }
  
    ngOnInit() {
      this.captchaExampleForm = this.fb.group({
        captcha: ['', [Validators.required]]
      });
    }
  
  exampleFormSubmit(){
  return false;
     }
  }
  </code></pre>
  
  <p>//captcha-test.spec.ts</p>
  
  <pre><code>import { async, ComponentFixture, TestBed } from 
  "@angular/core/testing";
  import { HttpClientModule } from "@angular/common/http";
  import { CaptchaTestComponent } from "./captcha-test.component";
  import { BrowserAnimationsModule } from "@angular/platform- 
  browser/animations";
  import { RouterTestingModule } from "@angular/router/testing";
  import { MatProgressSpinnerModule, MatFormFieldModule, MatInputModule } 
  from "@angular/material";
  import { ReactiveFormsModule, FormBuilder } from "@angular/forms";
  import { TestConstants } from "src/app/test/constants";
  import { NgxCaptchaModule } from "ngx-captcha";
  
  describe("CaptchaTestComponent", () =&gt; {
  jasmine.getEnv().allowRespy(true);
  let fixture: ComponentFixture&lt;CaptchaTestComponent&gt;;
  
  beforeEach(async(function () {
  TestBed.configureTestingModule({
    imports: [RouterTestingModule, BrowserAnimationsModule,
      ReactiveFormsModule, HttpClientModule, MatProgressSpinnerModule,
      MatFormFieldModule, MatInputModule, NgxCaptchaModule],
    providers: [FormBuilder
    ],
    declarations: [CaptchaTestComponent]
    }).compileComponents();
  }));
  
  beforeEach(function () {
   fixture = TestBed.createComponent(CaptchaTestComponent);
   this.component = fixture.componentInstance;
   this.component.captchaExampleForm.controls["captcha"].setValue(TestConstan ts.validCaptcha); //manually set a string data as input data.
  
  fixture.detectChanges();
  });
  
  it("should init component properly", function () {
    this.component.ngOnInit();
    expect(this.component.captchaExampleForm).toBeDefined();
  });
  
  it("should return submit as false when we submit the form", async 
    function () {
      const result = await this.component.exapmleFormSubmit();
      expect(result).toBeFalsy();
    });
  });
  </code></pre>
  
  <p>I am using "ngx-captcha": "^5.0.4" version with Angular 6.</p>