angular2-recaptcha
angular2-recaptcha copied to clipboard
Google recaptcha lib is loaded more than once in unit tests
I have a wrapper around captcha component. The captcha component is imported in custom module namely UiModule. When I run unit tests, I have the following error;
Uncaught Error: ReCAPTCHA placeholder element must be empty
I checked this error. This error originates from loading google captcha library more than once. Here's the beforeEach function of wrapper component;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
UiModule
]
}).compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(CaptchaComponent);
component = fixture.componentInstance;
component.token = environment.captcha.testToken;
component.siteKey = environment.captcha.siteKey;
component.testMode = true;
fixture.detectChanges();
});
UiModule declaration has RecaptchaModule exports.
Do you have a solution in mind?
I don't have any solution currently.
Maybe, the component would unload google recaptcha lib after its ngOnDestroy hook is called? Is it possible @xmaestro ?
Were you able to find a workaround?