Questions about testing Vue components with the vue-testing-library utility.
Questions tagged [vue-testing-library]
54 questions
11
votes
1 answer
How to use Vue Testing Library with Nuxt.js?
I want to use Vue Testing Library in my Nuxt.js app. But straight after installing the package, launching a test triggers this error:
'vue-cli-service' is not recognized as an internal or external
command, operable program or batch file.
This is…

drake035
- 3,955
- 41
- 119
- 229
8
votes
2 answers
Using Vue Test Utils, how can I check if a button is disabled?
I'm testing a Vue component but I'm having trouble testing a button's disabled state. How can I access a button's disabled status in my tests?
I've tried using .attributes() but in this instance the method only returns the button properties that…

Jon_B
- 969
- 4
- 16
- 24
6
votes
2 answers
vue3 testing library - How to use globalProperties in tests
I am new to Vue and followed the recommendation to use vue testing library. The only issue is I can't seem to find a way to inject my code into globalProperties in render function.
Does anyone know of an example where I can inject or mock it…

devtime
- 83
- 1
- 4
5
votes
0 answers
How to mock useRoute() in vue testing library
I ran into a problem when running a component test that has a line inside it:
const route = useRoute(). I get an error: Cannot read properties of undefined (reading 'path'). Here is the test:
describe('Tariff card', () => {
const options = {
…

DroFront
- 51
- 3
4
votes
1 answer
Unit Testing Vue 3 Component that uses Pinia with Vue Testing Library
I am struggling to understand how I can test the rendering of items based on the results of a call to a Pina getter in my Vue 3 app (using the Vue Testing Library). An example of what I want to achieve might be something like:

Richard Shergold
- 572
- 1
- 8
- 21
3
votes
0 answers
VeeValidate4. How to test custom field Component which uses useField?
I tried to test my custom input component. But I don't know how to do it right, because I didn't find any info how to test it.
The only thing I found was from this Mocking Form and Field Contexts
My custom component: