vue-debounce
vue-debounce copied to clipboard
Put some information for testing inside vue utils
Can you add some information on how to test a component with debounce directive. Thx
Sorry, I've been swamped with work things to really look into this, so I'm still researching the best approach.
@Natega FYI I just ended up building a mocked directive :
export const vueDebounceMockDirective = {
created(el: any, binding: { value: (...args: any[]) => void }) {
const debouncedFn = binding.value;
el.addEventListener('input', (event: any) => {
debouncedFn(event.target.value);
});
}
};
And I use it in my test like this :
// MountingOptions
options = {
global: {
// ...
directives: {
debounce: vueDebounceMockDirective
}
},
It works well using vue-test-utils setValue.
Good luck everyone ! And thank you @dhershman1 for the great lib !