What is the most effective method for testing an event listener code in background.js within a Chrome extension without a user interface?
Imagine you have the following background.js:
chrome.runtime.onMessage.addListener(request => {
console.log(request);
});
Now, you want to troubleshoot different types of messages (e.g.
chrome.runtime.sendMessage('someMessage')
) and observe the execution of console.log
. Despite attempting to use Chrome's DevTools for the background page and sending a message from the console, the console.log
line remains unexecuted.
If anyone can provide assistance, it would be greatly appreciated.