Vue-test-utils: Marking deprecated methods in docs

Created on 7 May 2020  路  3Comments  路  Source: vuejs/vue-test-utils

What problem does this feature solve?

Misunderstood in docs

### What does the proposed API look like?

Is it worth to mark deprecated methods with some warning? And maybe worth to mention about using @testing-library/jest-dom as replace? Since in cli we have deprecation message, in docs we don't have such info.

Don't know why but it took me a minute to figure out that I need to use .element in my assert method to use i.e. toBeEmpty(). Maybe it's also worth to mention in docs.

so it looks like this now

expect(wrapper.find('.empty-el').element).toBeEmpty()

instead of:

expect(wrapper.find('.empty-el').isEmpty()).toBe(true)

Most helpful comment

@afontcu Thanks for pointing that out, but that's not a solution for checking if methods get called on mounted for example, as you can't mock/spy them anymore.

I guess the solution is to not test if those methods are called, but if their effects are applied. That's all good, until you deal with the DOM (where Jest/JSDOM in some cases severely lacks functionality).

Maybe some of us are approaching testing wrong (could totally be the case), but there should still be an explanation for deprecations, as well as documentation on how to solve them :)

All 3 comments

I would also like to see solutions mentioned to deprecations.

Things like [vue-test-utils]: overwriting methods via the 'methods' property is deprecated and will be removed in the next major version are incredibly unhelpful if there's no alternative offered and nothing to be found in the docs either.

I would also like to see solutions mentioned to deprecations.

Things like [vue-test-utils]: overwriting methods via the 'methods' property is deprecated and will be removed in the next major version are incredibly unhelpful if there's no alternative offered and nothing to be found in the docs either.

Hi! 馃憢馃槃

This answer (and the following conversation) might help to understand why methods is removed and why there's no direct alternative.

@afontcu Thanks for pointing that out, but that's not a solution for checking if methods get called on mounted for example, as you can't mock/spy them anymore.

I guess the solution is to not test if those methods are called, but if their effects are applied. That's all good, until you deal with the DOM (where Jest/JSDOM in some cases severely lacks functionality).

Maybe some of us are approaching testing wrong (could totally be the case), but there should still be an explanation for deprecations, as well as documentation on how to solve them :)

Was this page helpful?
0 / 5 - 0 ratings