From 44ac5708035f10642816ab620b4fa3a83acf306f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A0=20Fontcuberta?= Date: Fri, 8 May 2020 07:09:39 +0200 Subject: [PATCH] Sync docs with v1.0 (#1538) * docs: add warnings on deprecated methods * docs: remove unused prop * docs: add deprecation warning on attachToDocument * docs: remove beta from readme * chore: remove beta.33 release file --- README.md | 5 ++-- RELEASE_NOTE_1.0.0-beta.33.md | 14 ----------- docs/api/options.md | 33 ++++++++++++------------- docs/api/wrapper-array/isEmpty.md | 8 ++++++ docs/api/wrapper-array/isVueInstance.md | 4 +++ docs/api/wrapper-array/setMethods.md | 4 +++ docs/api/wrapper/emittedByOrder.md | 6 +++++ docs/api/wrapper/find.md | 4 +++ docs/api/wrapper/findAll.md | 8 +++++- docs/api/wrapper/isEmpty.md | 8 ++++++ docs/api/wrapper/isVisible.md | 8 ++++++ docs/api/wrapper/isVueInstance.md | 4 +++ docs/api/wrapper/name.md | 4 +++ docs/api/wrapper/overview.md | 4 +++ docs/api/wrapper/setMethods.md | 4 +++ 15 files changed, 84 insertions(+), 34 deletions(-) delete mode 100644 RELEASE_NOTE_1.0.0-beta.33.md diff --git a/README.md b/README.md index 5f560e594..3337fb328 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,10 @@ # Vue Test Utils [![Build Status](https://circleci.com/gh/vuejs/vue-test-utils/tree/dev.png?style=shield)](https://circleci.com/gh/vuejs/vue-test-utils) +Vue Test Utils is the official testing library for Vue.js. + ## Packages -This repository provides the following two packages. -They are currently in beta. +This repository provides the following two packages: - [Vue Test Utils](./packages/test-utils) - [Vue Server Test Utils](./packages/server-test-utils) diff --git a/RELEASE_NOTE_1.0.0-beta.33.md b/RELEASE_NOTE_1.0.0-beta.33.md deleted file mode 100644 index bc5339ee4..000000000 --- a/RELEASE_NOTE_1.0.0-beta.33.md +++ /dev/null @@ -1,14 +0,0 @@ -# [1.0.0-beta.33](https://github.com/vuejs/vue-test-utils/compare/v1.0.0-beta.32...v1.0.0-beta.33) (2020-04-08) - -### Bug Fixes - -- **create-instance:** revert stubbing of component \_Ctor ([#1479](https://github.com/vuejs/vue-test-utils/issues/1479)) ([70b553b](https://github.com/vuejs/vue-test-utils/commit/70b553bd18158d82de5f26ff14c1f062be371245)) -- Add v-slot support in scopedSlots property, fix [#1457](https://github.com/vuejs/vue-test-utils/issues/1457) ([#1485](https://github.com/vuejs/vue-test-utils/issues/1485)) ([4df7619](https://github.com/vuejs/vue-test-utils/commit/4df7619c9388528718f0a39704fd22bd6dd669af)) -- **test-utils:** fix cancelable attribute in dom events ([#1460](https://github.com/vuejs/vue-test-utils/issues/1460)) ([b1a532a](https://github.com/vuejs/vue-test-utils/commit/b1a532aa72c71d2f4282f4bc31373cb143e82833)) -- Respect provide from parentComponent (#1301 -- #1377 string stubs dropping props (#1473) - -### Features - -- support lazy modifier with setValue ([#1467](https://github.com/vuejs/vue-test-utils/issues/1467)) ([afd7a82](https://github.com/vuejs/vue-test-utils/commit/afd7a82426c2e72fca61bf00881574d81dffbf68)) -- support object class binding in stubbed functional components ([#1476](https://github.com/vuejs/vue-test-utils/issues/1476)) ([55f7eac](https://github.com/vuejs/vue-test-utils/commit/55f7eac5cd305b60c0b9f8340cc6d9e3f470a665)) diff --git a/docs/api/options.md b/docs/api/options.md index 2b8f85904..9c346d68b 100644 --- a/docs/api/options.md +++ b/docs/api/options.md @@ -302,8 +302,7 @@ remove the rendered elements from the document and destroy the component instanc ```js const Component = { - template: '
ABC
', - props: ['msg'] + template: '
ABC
' } let wrapper = mount(Component, { attachTo: '#root' @@ -323,7 +322,11 @@ wrapper.destroy() - type: `boolean` - default: `false` -Like [`attachTo`](#attachto), but automatically creates a new `div` element for you and inserts it into the body. This is deprecated in favor of [`attachTo`](#attachto). +::: warning +`attachToDocument` is deprecated and will be removed in future releases. Use [`attachTo`](#attachto) instead. +::: + +Like [`attachTo`](#attachto), but automatically creates a new `div` element for you and inserts it into the body. When attaching to the DOM, you should call `wrapper.destroy()` at the end of your test to remove the rendered elements from the document and destroy the component instance. @@ -432,26 +435,22 @@ When the options for `mount` and `shallowMount` contain the options other than t ```js const Component = { - template: '
{{ foo() }}{{ bar() }}{{ baz() }}
', - methods: { - foo() { - return 'a' - }, - bar() { - return 'b' + template: '
{{ foo }}
', + data() { + return { + foo: 'fromComponent' } } } const options = { - methods: { - bar() { - return 'B' - }, - baz() { - return 'C' + data() { + return { + foo: 'fromOptions' } } } + const wrapper = mount(Component, options) -expect(wrapper.text()).toBe('aBC') + +expect(wrapper.text()).toBe('fromOptions') ``` diff --git a/docs/api/wrapper-array/isEmpty.md b/docs/api/wrapper-array/isEmpty.md index fd7895702..ff15b972f 100644 --- a/docs/api/wrapper-array/isEmpty.md +++ b/docs/api/wrapper-array/isEmpty.md @@ -1,5 +1,13 @@ ## isEmpty +::: warning +`isEmpty` is deprecated and will be removed in future releases. + +Consider a custom matcher such as those provided in [jest-dom](https://github.com/testing-library/jest-dom#tobeempty). + +When using with findComponent, access the DOM element with findComponent(Comp).element +::: + Assert every `Wrapper` in `WrapperArray` does not contain child node. - **Returns:** `{boolean}` diff --git a/docs/api/wrapper-array/isVueInstance.md b/docs/api/wrapper-array/isVueInstance.md index 126b796e8..a27221a1b 100644 --- a/docs/api/wrapper-array/isVueInstance.md +++ b/docs/api/wrapper-array/isVueInstance.md @@ -1,5 +1,9 @@ ## isVueInstance +::: warning +`isVueInstance` is deprecated and will be removed in future releases. +::: + Assert every `Wrapper` in `WrapperArray` is Vue instance. - **Returns:** `{boolean}` diff --git a/docs/api/wrapper-array/setMethods.md b/docs/api/wrapper-array/setMethods.md index 3cb064858..b9e1ebc94 100644 --- a/docs/api/wrapper-array/setMethods.md +++ b/docs/api/wrapper-array/setMethods.md @@ -1,5 +1,9 @@ ## setMethods +::: warning +`setMethods` is deprecated and will be removed in future releases. +::: + Sets `Wrapper` `vm` methods and forces update on each `Wrapper` in `WrapperArray`. **Note every `Wrapper` must contain a Vue instance.** diff --git a/docs/api/wrapper/emittedByOrder.md b/docs/api/wrapper/emittedByOrder.md index 758664d40..38f82eb77 100644 --- a/docs/api/wrapper/emittedByOrder.md +++ b/docs/api/wrapper/emittedByOrder.md @@ -1,5 +1,11 @@ ## emittedByOrder +::: warning +`emittedByOrder` is deprecated and will be removed in future releases. + +Use `wrapper.emitted` instead. +::: + Return an Array containing custom events emitted by the `Wrapper` `vm`. - **Returns:** `Array<{ name: string, args: Array }>` diff --git a/docs/api/wrapper/find.md b/docs/api/wrapper/find.md index 98547914a..d4409d669 100644 --- a/docs/api/wrapper/find.md +++ b/docs/api/wrapper/find.md @@ -1,5 +1,9 @@ ## find +::: warning +Using `find` to search for a Component is deprecated and will be removed. Use `findComponent` instead. +::: + Returns `Wrapper` of first DOM node or Vue component matching selector. Use any valid DOM selector (uses `querySelector` syntax). diff --git a/docs/api/wrapper/findAll.md b/docs/api/wrapper/findAll.md index d062f72b3..758823fbb 100644 --- a/docs/api/wrapper/findAll.md +++ b/docs/api/wrapper/findAll.md @@ -1,5 +1,9 @@ ## findAll +::: warning +Using `findAll` to search for Components is deprecated and will be removed. Use `findAllComponents` instead. +::: + Returns a [`WrapperArray`](../wrapper-array/). Use any valid [selector](../selectors.md). @@ -18,8 +22,10 @@ import Foo from './Foo.vue' import Bar from './Bar.vue' const wrapper = mount(Foo) + const div = wrapper.findAll('div').at(0) expect(div.is('div')).toBe(true) -const bar = wrapper.findAll(Bar).at(0) + +const bar = wrapper.findAll(Bar).at(0) // Deprecated usage expect(bar.is(Bar)).toBe(true) ``` diff --git a/docs/api/wrapper/isEmpty.md b/docs/api/wrapper/isEmpty.md index f83548282..0858c4ad5 100644 --- a/docs/api/wrapper/isEmpty.md +++ b/docs/api/wrapper/isEmpty.md @@ -1,5 +1,13 @@ ## isEmpty +::: warning +`isEmpty` is deprecated and will be removed in future releases. + +Consider a custom matcher such as those provided in [jest-dom](https://github.com/testing-library/jest-dom#tobeempty). + +When using with findComponent, access the DOM element with `findComponent(Comp).element` +::: + Assert `Wrapper` does not contain child node. - **Returns:** `{boolean}` diff --git a/docs/api/wrapper/isVisible.md b/docs/api/wrapper/isVisible.md index d2456c18a..f236bd74a 100644 --- a/docs/api/wrapper/isVisible.md +++ b/docs/api/wrapper/isVisible.md @@ -1,5 +1,13 @@ ## isVisible +::: warning +`isVisible` is deprecated and will be removed in future releases. + +Consider a custom matcher such as those provided in [jest-dom](https://github.com/testing-library/jest-dom#tobevisible). + +When using with findComponent, access the DOM element with `findComponent(Comp).element` +::: + Assert `Wrapper` is visible. Returns `false` if an ancestor element has `display: none` or `visibility: hidden` style. diff --git a/docs/api/wrapper/isVueInstance.md b/docs/api/wrapper/isVueInstance.md index 4627e955b..aa6218437 100644 --- a/docs/api/wrapper/isVueInstance.md +++ b/docs/api/wrapper/isVueInstance.md @@ -1,5 +1,9 @@ ## isVueInstance +::: warning +`isVueInstance` is deprecated and will be removed in future releases. +::: + Assert `Wrapper` is Vue instance. - **Returns:** `{boolean}` diff --git a/docs/api/wrapper/name.md b/docs/api/wrapper/name.md index 458bae5cc..a793a7081 100644 --- a/docs/api/wrapper/name.md +++ b/docs/api/wrapper/name.md @@ -1,5 +1,9 @@ ## name +::: warning +`name` is deprecated and will be removed in future releases. +::: + Returns component name if `Wrapper` contains a Vue instance, or the tag name of `Wrapper` DOM node if `Wrapper` does not contain a Vue instance. - **Returns:** `{string}` diff --git a/docs/api/wrapper/overview.md b/docs/api/wrapper/overview.md index 2130b6e46..dd3c9a650 100644 --- a/docs/api/wrapper/overview.md +++ b/docs/api/wrapper/overview.md @@ -1,5 +1,9 @@ ## overview +::: warning +`overview` is deprecated and will be removed in future releases. +::: + Prints a simple overview of the `Wrapper`. - **Example:** diff --git a/docs/api/wrapper/setMethods.md b/docs/api/wrapper/setMethods.md index e49062591..124c0e6ac 100644 --- a/docs/api/wrapper/setMethods.md +++ b/docs/api/wrapper/setMethods.md @@ -1,5 +1,9 @@ ## setMethods +::: warning +`setMethods` is deprecated and will be removed in future releases. +::: + Sets `Wrapper` `vm` methods and forces update. **Note the Wrapper must contain a Vue instance.**