Open
Description
Please search other issues to make sure this bug has not already been reported. ✅
Hey team, thanks for supporting this library.
Describe the bug
If you want to stub out getStore
using Sinon
you'll get an error like this:
TypeError: Descriptor for property getStore is non-configurable and non-writable
E.g. in a test file like this
import sinon from "sinon";
import * as netlifyBlobs from "@netlify/blobs";
import { type Store } from "@netlify/blobs";
describe("thing", () => {
let mockStore: Partial<Store>;
let setStub: sinon.SinonStub;
let getStoreStub: sinon.SinonStub;
beforeEach(() => {
setStub = sinon.stub().resolves();
mockStore = {
set: setStub,
};
getStoreStub = sinon.stub(netlifyBlobs, "getStore").returns(mockStore as Store);
});
- Is it because
getStore
is exported as aconst
here? - Why export a function as a
const
? I've not seen that before - How do you recommend people mock / stub out your package
I can just wrap getStore
in a module and mock that but it feels like a shame to introduce that complexity to my codebase.