[Vue 3] Update DatePicker value using vue-test-utils

0 Answers 30 Views
DateInput DatePicker DateTimePicker
Palmer
Top achievements
Rank 1
Palmer asked on 25 Jun 2025, 05:52 PM | edited on 25 Jun 2025, 05:55 PM

Hello, I am using the DatePicker component from the @progress/kendo-vue-dateinputs package.

I am trying to update the value of the date picker in a unit test using vue-test-utils.

I have tried the following, which is how I would ordinarily update input values:

const input = wrapper.find('input[id="my-date-field"]'); endDateInput.setValue('01/01/2025');

await nextTick();

endDateInput.trigger('change');

await nextTick();

This does seem to update the value, but does not update it correctly.

A snapshot of the markup after setting the value this way shows that it appears to set the year based on the last 2 digits of the new value, but not correctly, and it is also missing the dd/mm parts:

<input role="combobox"class="k-input-inner" id="my-date-field" value="dd/mm/0025" etc...>

Is there a way in which I can update the date picker value correctly?

I appreciate that the calendar popup is appended to <body>, so setting the value using that programatically is not possible, but any way of being able to update the input value is fine.

Happy to provide a minimal repro if required.

Filip
Telerik team
commented on 30 Jun 2025, 12:06 PM

Hi, Palmer,

I can suggest triggering the DatePicker’s change event with a Date object, then updating `change` the prop:
import { nextTick } from 'vue';

const datePickerWrapper = wrapper.findComponent({ name: 'DatePicker' });

// Simulate Kendo DatePicker change event
await datePickerWrapper.trigger('change', { value: new Date('2025-01-01') });

// Simulate parent updating the value prop
await wrapper.setProps({ value: new Date('2025-01-01') });

await nextTick();
In case this approach does not work, can you please send us a minimal repro of the issue? This will enable us to debug it locally and provide more feedback.

Regards,
Filip

No answers yet. Maybe you can help?

Tags
DateInput DatePicker DateTimePicker
Asked by
Palmer
Top achievements
Rank 1
Share this question
or