acvetkov / sinon-chrome

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

chrome.storage.local.get === chrome.storage.sync.get #66

Closed ghost closed 6 years ago

ghost commented 6 years ago
const chrome = require( 'sinon-chrome' );
const chai = require( 'chai' );
chai.use( require( 'sinon-chai' ) );
const expect = chai.expect;

expect( chrome.storage.sync.get ).not.to.equal( chrome.storage.local.get ); // fails, these are equal

expect( chrome.storage.sync.get ).not.to.have.been.called;
expect( chrome.storage.local.get ).not.to.have.been.called;
chrome.storage.sync.get( 'test' );
expect( chrome.storage.sync.get ).to.have.been.called;
expect( chrome.storage.local.get ).not.to.have.been.called; // fails

I found this after hours of trying to figure out why my test was failing where I was testing that my extension loads from sync storage and not from local storage.