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

Type definitions not working with chrome.tabs.query #13

Open
vquigley opened this issue Feb 3, 2022 · 2 comments
Open

Type definitions not working with chrome.tabs.query #13

vquigley opened this issue Feb 3, 2022 · 2 comments

Comments

@vquigley
Copy link

vquigley commented Feb 3, 2022

TS linter is throwing an error when trying to mock chrome.tabs.query

image

I think this is happening because chrome is overloading the query function name in their type definition:

image

But the jest definition only has one definition for the mocked function:

image

@adlerfaulkner
Copy link

adlerfaulkner commented Feb 14, 2022

+1 when using chrome.tabs.get in a test

@adlerfaulkner
Copy link

For anyone with this problem, you can trick typescript by casting the api method to jest.Mock like this:

(chrome.tabs.get as jest.Mock).mockImplementation( ... )

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

2 participants