You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 a consthere?
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.
The text was updated successfully, but these errors were encountered:
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
usingSinon
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
getStore
is exported as aconst
here?const
? I've not seen that beforeI can just wrap
getStore
in a module and mock that but it feels like a shame to introduce that complexity to my codebase.The text was updated successfully, but these errors were encountered: