question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Install `@testing-library/vue` by default instead of `@vue/test-utils`

See original GitHub issue

What problem does this feature solve?

In the official documentation on testing, the following is mentioned when suggesting the 2 libraries that can be used for testing:

Vue Test Utils is the official low-level component testing library that was written to provide users access to Vue specific APIs. If you are new to testing Vue applications, we would recommend using Vue Testing Library, which is an abstraction over Vue Test Utils.

The recommendation for new users is to use @testing-library/vue. However, @vue/cli-plugin-unit-jest doesn’t actually install @testing-library/vue, but @vue/test-utils

I find it to be unintuitive that despite the recommendation, the more low-level (and “harder to use”) alternative is installed by default.

It’s probably not a good idea to install both by default, but if we have to pick one, @testing-library/vue seems like the obvious choice to me.

The users who would be more likely to go with @vue/test-utils instead, are more likely to be more experienced, and will have a better understanding of the alternatives.

What does the proposed API look like?

Change https://github.com/vuejs/vue-cli/blob/82aef123d9e4bbeec397023edc0c820672f79c8f/packages/%40vue/cli-plugin-unit-jest/generator/index.js#L15 to add @testing-library/vue instead

Happy to open a PR on this myself

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
afontcucommented, Feb 7, 2021

Hi! Vue Testing Library maintainer here. 👋

We’re still ironing out our integration with Vue 3, but we’re almost there. I’ll keep an eye on this issue and ping you back when VTL for Vue 3 is marked as stable.

It’s probably not a good idea to install both by default

Actually Vue Testing Library relies on Vue Test Utils, so you might end up with both libraries installed under the hood (even though you might only want to use VTL 😄)

Thanks!

1reaction
sodateacommented, Jan 21, 2021

Yeah, it would be great to use an easier-to-use testing library by default. But I have zero experience with it. So any PR is very welcome!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Testing Vue Applications With The Vue Testing Library
By default, installing Jest with the Vue CLI plugin will install @vue/test-utils , hence the above test file is using the shallowMount ...
Read more >
Testing vue-testing-library | by Daniel Gonzalez - Medium
I'll describe the difficulties to set up the testing environment with ... Vue Test Utils is the official testing library for Vue.js.
Read more >
Testing Vue components with Vue Testing Library
Run the command below to set up a new Vue project. vue create testing-vue-components. We can stick to the default Vue configurations since ......
Read more >
@testing-library/vue - npm
npm install --save-dev @testing-library/vue. This library has peerDependencies listings for Vue 3 and vue-template-compiler .
Read more >
Testing - Vue.js
The longer you wait to add tests to your application, the more dependencies ... @vue/test-utils is the official low-level component testing library that...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found