Open ashkan117 opened 3 weeks ago
I've stumbled upon this error in a different context. It's because sonner does an outdated check if a promise is a Promise
.
This is the responsible line of code: src/state.ts#L124
A promise doesn't need to be an instance of Promise
to be a promise (yeah ... I know). It only needs to have a .then() method. This Stackoverflow answer has a good summary.
TL;DR: Sonner should use Promise.resolve(foo)
instead of testing for type.
Describe the feature / bug 📝:
I'm currently using sonner like the following
When testing I want to mock out this api call but when used in tandem with sonner this fails with the following error.
A workaround I am using is to manually handle the states with the
apiCall.then().catch()
methodsSteps to reproduce the bug 🔁:
jest.spyOn
I can try to add more details so let me know what else might be useful.