Closed kaamosfirefly closed 8 years ago
Why not proxyquire for testing?
import proxyquire from 'proxyquire';
const MyComponent = proxyquire('./myComponent', {
'lodash.debounce': callback => callback()
});
I would also recommend to do shallow rendering, so you will not render DebounceInput at all and there will not be any need for proxying or mocking debounce.
In general, testing DebounceInput is a concern of DebounceInput itself, not your application.
Closing this for now, feel free to reopen though, if you have any more questions/details around it.
Cheers!
When testing react components that use the debouncer input, it would be nice to be able to have the debouncer used by this component to use the given context. Example: when using sinon fakeTimers, the global setTimeout is replaced by a mocked one, but the setTimeout used in lodash isn't which makes testing the parents of this component difficult.