Skip to content

Commit c94c589

Browse files
authored
fix #1541: Improve deprecation messages (#1548)
* docs: improve title on deprecation warnings * docs: add suggestion for isVueInstance * refactor: improve migration path for setMethods and options.methods * docs: fix link format * docs: add more hints to replace setMethods and options.methods * docs: reword messages * docs: remove implicit statement
1 parent 7e36d77 commit c94c589

File tree

16 files changed

+95
-15
lines changed

16 files changed

+95
-15
lines changed

docs/api/options.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ wrapper.destroy()
322322
- type: `boolean`
323323
- default: `false`
324324

325-
::: warning
325+
::: warning Deprecation warning
326326
`attachToDocument` is deprecated and will be removed in future releases. Use [`attachTo`](#attachto) instead.
327327
:::
328328

docs/api/wrapper-array/isEmpty.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## isEmpty
22

3-
::: warning
3+
::: warning Deprecation warning
44
`isEmpty` is deprecated and will be removed in future releases.
55

66
Consider a custom matcher such as those provided in [jest-dom](https://github.com/testing-library/jest-dom#tobeempty).

docs/api/wrapper-array/isVueInstance.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
## isVueInstance
22

3-
::: warning
3+
::: warning Deprecation warning
44
`isVueInstance` is deprecated and will be removed in future releases.
5+
6+
Tests relying on the `isVueInstance` assertion provide little to no value. We suggest replacing them with purposeful assertions.
7+
8+
To keep these tests, a valid replacement for `isVueInstance()` is a truthy assertion of `wrapper.find(...).vm`.
59
:::
610

711
Assert every `Wrapper` in `WrapperArray` is Vue instance.

docs/api/wrapper-array/setMethods.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
## setMethods
22

3-
::: warning
3+
::: warning Deprecation warning
44
`setMethods` is deprecated and will be removed in future releases.
5+
6+
There's no clear path to replace `setMethods`, because it really depends on your previous usage. It easily leads to flaky tests that rely on implementation details, which [is discouraged](https://github.com/vuejs/rfcs/blob/668866fa71d70322f6a7689e88554ab27d349f9c/active-rfcs/0000-vtu-api.md#setmethods).
7+
8+
We suggest rethinking those tests.
9+
10+
To stub a complex method extract it from the component and test it in isolation. To assert that a method is called, use your test runner to spy on it.
511
:::
612

713
Sets `Wrapper` `vm` methods and forces update on each `Wrapper` in `WrapperArray`.

docs/api/wrapper/emittedByOrder.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## emittedByOrder
22

3-
::: warning
3+
::: warning Deprecation warning
44
`emittedByOrder` is deprecated and will be removed in future releases.
55

66
Use `wrapper.emitted` instead.

docs/api/wrapper/find.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## find
22

3-
::: warning
3+
::: warning Deprecation warning
44
Using `find` to search for a Component is deprecated and will be removed. Use `findComponent` instead.
55
:::
66

docs/api/wrapper/findAll.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## findAll
22

3-
::: warning
3+
::: warning Deprecation warning
44
Using `findAll` to search for Components is deprecated and will be removed. Use `findAllComponents` instead.
55
:::
66

docs/api/wrapper/isEmpty.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## isEmpty
22

3-
::: warning
3+
::: warning Deprecation warning
44
`isEmpty` is deprecated and will be removed in future releases.
55

66
Consider a custom matcher such as those provided in [jest-dom](https://github.com/testing-library/jest-dom#tobeempty).

docs/api/wrapper/isVisible.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## isVisible
22

3-
::: warning
3+
::: warning Deprecation warning
44
`isVisible` is deprecated and will be removed in future releases.
55

66
Consider a custom matcher such as those provided in [jest-dom](https://github.com/testing-library/jest-dom#tobevisible).

docs/api/wrapper/isVueInstance.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
## isVueInstance
22

3-
::: warning
3+
::: warning Deprecation warning
44
`isVueInstance` is deprecated and will be removed in future releases.
5+
6+
Tests relying on the `isVueInstance` assertion provide little to no value. We suggest replacing them with purposeful assertions.
7+
8+
To keep these tests, a valid replacement for `isVueInstance()` is a truthy assertion of `wrapper.find(...).vm`.
59
:::
610

711
Assert `Wrapper` is Vue instance.

0 commit comments

Comments
 (0)