acvetkov / sinon-chrome

Testing chrome extensions with Node.js
ISC License
435 stars 46 forks source link

chrome.storage.local.get never executes #55

Closed warent closed 7 years ago

warent commented 7 years ago

I'm testing with Jest 19.0.2, and when I try to use:

chrome.storage.local.get(key, val => console.log(val))

It will never actually execute the anonymous function and log anything. Is this expected behavior?

acvetkov commented 7 years ago

@warent hi!

chrome.storage.local.get is sinon stub, you should define behavior.

chrome.storage.local.get.yields('result');
// or
chrome.storage.local.get.withArgs('key').yields('value_for_key');
warent commented 7 years ago

That's it. Sinon is new to me; definitely will do some reading. Thank you for the help :)