question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to test chrome extension API?

See original GitHub issue

In a function changeExtensionTooltip I have a line of code like this:

chrome.browserAction.setTitle({title: text});

And I want to assert that method chrome.browserAction.setTitle has been called once and that it has received {title: 'WakaTime'}.

Can someone help with this? @Stephn-R

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
stephnrcommented, Jun 30, 2015

Hey @mabasic, its very easy to do exactly that. Since Jest is a descendant of Jasmine, you can use the Spy tool to do this

spyOn(chrome.browserAction.setTitle);
// do some stuff
expect(chrome.browserAction.setTitle).toHaveBeenCalled();
// or
expect(chrome.browserAction.setTitle).toHaveBeenCalledWith({ title: text });
Read more comments on GitHub >

github_iconTop Results From Across the Web

Using the chrome.test API
The chrome.test extension API is a limited testing framework implemented as an extension API. It is primarily used in order to provide testing...
Read more >
How to test chrome extensions? - Stack Overflow
If you want to test pages directly, you can orchestrate your extension to open new tabs (chrome.tab.create({"url" : "someurl"}). For each of the...
Read more >
Talend API Tester - Free Edition
Talend API Tester makes it easy to invoke, discover and test HTTP and ... Chrome extensions which need access to internet resources must ......
Read more >
API reference - Chrome Developers
The complete reference to all APIs made available to Chrome Extensions. This includes APIs for the deprecated Chrome Apps platform as well as...
Read more >
Complete Guide to Test Chrome Extensions with Puppeteer
Testing strategy​ · Open a browser tab with the target application. · Load the browser extension and open the popup in a new...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found