Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google recaptcha lib is loaded more than once in unit tests #66

Open
aacanakin opened this issue Jun 1, 2017 · 3 comments
Open

Google recaptcha lib is loaded more than once in unit tests #66

aacanakin opened this issue Jun 1, 2017 · 3 comments

Comments

@aacanakin
Copy link

aacanakin commented Jun 1, 2017

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.

@xmaestro
Copy link
Owner

xmaestro commented Jun 5, 2017

Do you have a solution in mind?

@aacanakin
Copy link
Author

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 ?

@xmaestro
Copy link
Owner

xmaestro commented Aug 1, 2017

Were you able to find a workaround?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants