Why the ||= assignment? Also, if you're stubbing out the whole object and it has non-trivial behavior of state, it's clearer to define the stub as its own object with a name (e.g. SyncStorageStub) and then assign it to global.chrome.storage.