0

I have a tricky situation over here. I have used an npm module:- use-places-autocomplete to get autocomplete suggestions from google maps autocomplete API. Below is the link for the npm module and the CDN link I am using in my react app in public index.html.

Link:- https://www.npmjs.com/package/use-places-autocomplete CDN:- "https://maps.googleapis.com/maps/api/js?key={MY_API_KEY}&libraries=places&region=us"

The issue is coming when I am testing this link in tests. I am using Jest and React testing library. I am not getting any response (mock response which i have hardcoded in the codebase) when i start typing in the address.

I have tried the following things:-

Mocking the use-places-autocomplete response. But it did not work. Using MSW for intercepting the CDN. It also didnt work. In the test suite, adding the script of Google API in beforEach and then rendering the component. It also didnt work.

Can anybody please help me in this. Thanks in advance.

maverick
  • 82
  • 2
  • 15

0 Answers0