diff --git a/docs/api/wrapper-array/README.md b/docs/api/wrapper-array/README.md index 6f252df0b..114007fbe 100644 --- a/docs/api/wrapper-array/README.md +++ b/docs/api/wrapper-array/README.md @@ -17,6 +17,7 @@ A `WrapperArray` is an object that contains an array of [`Wrappers`](../wrapper/ !!!include(docs/api/wrapper-array/at.md)!!! !!!include(docs/api/wrapper-array/contains.md)!!! !!!include(docs/api/wrapper-array/destroy.md)!!! +!!!include(docs/api/wrapper-array/exists.md)!!! !!!include(docs/api/wrapper-array/filter.md)!!! !!!include(docs/api/wrapper-array/is.md)!!! !!!include(docs/api/wrapper-array/isEmpty.md)!!! diff --git a/docs/api/wrapper-array/exists.md b/docs/api/wrapper-array/exists.md new file mode 100644 index 000000000..9e2d3f79e --- /dev/null +++ b/docs/api/wrapper-array/exists.md @@ -0,0 +1,19 @@ +## exists + +Assert `WrapperArray` exists. + +Returns false if called on a `WrapperArray` with no `Wrapper` objects, or if +any of them do not exist. + +- **Returns:** `{boolean}` + +- **Example:** + +```js +import { mount } from '@vue/test-utils' +import Foo from './Foo.vue' + +const wrapper = mount(Foo) +expect(wrapper.findAll('div').exists()).toBe(true) +expect(wrapper.findAll('does-not-exist').exists()).toBe(false) +``` diff --git a/docs/api/wrapper/exists.md b/docs/api/wrapper/exists.md index a48dc6c0d..d88a2f958 100644 --- a/docs/api/wrapper/exists.md +++ b/docs/api/wrapper/exists.md @@ -1,8 +1,8 @@ ## exists -Assert `Wrapper` or `WrapperArray` exists. +Assert `Wrapper` exists. -Returns false if called on an empty `Wrapper` or `WrapperArray`. +Returns false if called on a `Wrapper` which does not exist. - **Returns:** `{boolean}` @@ -15,6 +15,4 @@ import Foo from './Foo.vue' const wrapper = mount(Foo) expect(wrapper.exists()).toBe(true) expect(wrapper.find('does-not-exist').exists()).toBe(false) -expect(wrapper.findAll('div').exists()).toBe(true) -expect(wrapper.findAll('does-not-exist').exists()).toBe(false) ``` diff --git a/packages/test-utils/src/wrapper.js b/packages/test-utils/src/wrapper.js index 569269894..82f98cce4 100644 --- a/packages/test-utils/src/wrapper.js +++ b/packages/test-utils/src/wrapper.js @@ -208,7 +208,7 @@ export default class Wrapper implements BaseWrapper { } /** - * Utility to check wrapper exists. Returns true as Wrapper always exists + * Utility to check wrapper exists. */ exists(): boolean { if (this.vm) {