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

Testing variants with Jest #485

Open
jeremias-jalil opened this issue Jan 21, 2022 · 1 comment
Open

Testing variants with Jest #485

jeremias-jalil opened this issue Jan 21, 2022 · 1 comment

Comments

@jeremias-jalil
Copy link

I have managed to implement the library successfully, but I am having problems when carrying out the tests using jest, since I cannot get it to render any of the variants.

How should I make the variants render in the jest test?

Thank you.

@jeremias-jalil
Copy link
Author

I have found a solution. Mocking the response expected by the component.

declare global {
  interface Window {
    google_optimize: {
         get: Function
      }
  }
}

window.google_optimize = {
  get: jest.fn().mockImplementation(() => null )
};

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

1 participant