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

Problem with mocking the Loader in Jest #643

Open
Hajzenberg opened this issue Jun 12, 2022 · 0 comments
Open

Problem with mocking the Loader in Jest #643

Hajzenberg opened this issue Jun 12, 2022 · 0 comments
Assignees
Labels
triage me I really want to be triaged. type: question Request for information or clarification. Not an issue.

Comments

@Hajzenberg
Copy link

Hajzenberg commented Jun 12, 2022

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?

@Hajzenberg Hajzenberg added triage me I really want to be triaged. type: question Request for information or clarification. Not an issue. labels Jun 12, 2022
@Hajzenberg Hajzenberg changed the title Problem with mocking the loader Problem with mocking the Loader Jun 12, 2022
@Hajzenberg Hajzenberg changed the title Problem with mocking the Loader Problem with mocking the Loader in Jest Jun 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage me I really want to be triaged. type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

2 participants