'Jest - How to test GoogleMapsApiLoader

I am using the google map api loader for get the google map config details. Ref: https://v2.vuejs.org/v2/cookbook/practical-use-of-scoped-slots.html#1-Create-a-component-that-initializes-our-map

I am trying to cover unit test case for this scenario.

googleMap.vue

async mounted() {
    const googleMapApi = await GoogleMapsApiLoader({
      apiKey: this.apiKey
    })
    this.google = googleMapApi
    this.initializeMap()
},

googleMap.spec.js

jest.mock('google-maps-api-loader', () => {
  return { ... }
});
require('google-maps-api-loader');
const wrapper = shallowMount(GoogleMap, {
    propsData: {
      mapConfig: {},
      apiClient: 'apiclient-test-id',
      apiChannel: 'apichannel-test-id'
    },
    mocks: {
      mocksData
    }
});

describe('googlemap.vue', () => {
  it('should all the elements rendered', async() => {
    wrapper = mountGoogleMap();
  });
});

Those given line was not covering.. I am struggling to write unit test case for this file



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source