js-api-loader
js-api-loader copied to clipboard
Problem with mocking the Loader in Jest
I'm trying to mock the Loader in Jest so I can test if loader.load() method is being invoked in my code.
I've tried with:
jest.mock('@googlemaps/js-api-loader', () => {
const actual = jest.requireActual('@googlemaps/js-api-loader');
return {
...actual,
Loader: jest.fn().mockImplementation(() => {
return {
load: jest.fn(),
};
}),
};
});
But during the test invocation is fails with loader.load is not a function. Any idea how to mock it successfully?