Unit Testing with PrimeVue
Posted: 13 Oct 2021, 14:27
Is there a trick to writing Unit Tests when using PrimeVue components?
(I'm new to Vue, PrimeVue AND Unit Testing!)
I have an InputText component in my template like this:
I am writing the following in my unit test:
but I get the following error:
I also tried this:
but that didn't seem to set the value.
What is the correct way of setting the value of my InputText component in a unit test?
Can anyone offer any assistance??
thanks
(I'm new to Vue, PrimeVue AND Unit Testing!)
I have an InputText component in my template like this:
Code: Select all
<InputText
data-testid="new-delivery-method"
size="50"
id="deliveryMethod"
type="text"
placeholder="New Delivery Method"
v-model="newDeliveryMethod"
/>
Code: Select all
const inputBox = wrapper.find('[data-testid="new-delivery-method"]');
await inputBox.setValue("Our New Method")
Code: Select all
wrapper.setValue() cannot be called on INPUTTEXT" ?
Code: Select all
const inputBox = wrapper.find('[data-testid="new-delivery-method"]');
const inputBox = wrapper.find('InputText')
inputBox.element.value = 'Our New Method';
inputBox.trigger('input')
What is the correct way of setting the value of my InputText component in a unit test?
Can anyone offer any assistance??
thanks