Mock Chrome Storage API to test extension popup

I am building a chrome extension. For this I use the Chrome Storage API in a script that runs when the popup is opened (popup.js):

chrome.storage.sync.get(...);

However, it’s much easier to develop and test the popup if I open it directly in the browser as its own web page instead of just testing it as an actual popup, since I then also have Inspect element and similar tools.
The only problem is that the Storage API is meant for extensions and any uses of it in my code will directly result in an error when I open the popup as a web page. So I thought it would be useful to just mock the API calls. Then I could simulate storage data as well. To do this, so far I’m using something like the following at the top of popup.js:

let chrome = {
    storage: {
        sync: {
            get: function (a, b) {console.log("[Mock] get-Function"); },
        }
    },
}

(Of course, to really simulate storage data this would need more than an empty function)

The problem is, however, that I only want to use the mocking for testing the popup, of course, and not for testing the addon or in production. For production I already have my own build process with webpack, which bundles the whole thing for me.
Is it possible that I create a similar build process (possibly also with webpack) that I can then run from the command line and that actively includes mocking in the code, for example by adding it as a dependency.
Or what is basically the best approach if you want to use a piece of code for some special test processes and never otherwise?

So far, I’ve tried creating my own file that overrides the Chrome API with empty functions and exports that. popup.js should then check if this file exists and if so import the overridden functions. This would work in itself, if webpack didn’t also always bundle the mock file with the production build. It was not possible for me to get webpack to ignore dependencies completely by any settings.