Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(test-utils): add 'overview' function (#1491)
* feat(test-utils): add 'overview' function close #1461 * feat(test-utils): add error wrapper overview * fix(test-utils): fix flow errors * fix(test-utils): compatibility with older versions * fix(test utils): flow error * feat: overview function PR comments Co-authored-by: root <root@LAPTOP-VOQ3N65A.localdomain>
- Loading branch information
Showing
8 changed files
with
565 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
## overview | ||
|
||
Prints a simple overview of the `Wrapper`. | ||
|
||
- **Example:** | ||
|
||
```js | ||
import { mount } from '@vue/test-utils' | ||
import Component from './Component.vue' | ||
|
||
const wrapper = mount(Component) | ||
wrapper.overview() | ||
|
||
// Console output | ||
/* | ||
Wrapper (Visible): | ||
Html: | ||
<div class="test"> | ||
<p>My name is Tess Ting</p> | ||
</div> | ||
Data: { | ||
firstName: Tess, | ||
lastName: Ting | ||
} | ||
Computed: { | ||
fullName: Tess Ting' | ||
} | ||
Emitted: {', | ||
foo: [', | ||
0: [ hello, world ], | ||
1: [ bye, world ]' | ||
], | ||
bar: [ | ||
0: [ hey ]' | ||
] | ||
} | ||
*/ | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { describeWithShallowAndMount } from '~resources/utils' | ||
import { compileToFunctions } from 'vue-template-compiler' | ||
import '@vue/test-utils' | ||
|
||
describeWithShallowAndMount('overview', mountingMethod => { | ||
it('throws error if wrapper array contains no items', () => { | ||
const wrapper = mountingMethod(compileToFunctions('<div />')) | ||
const message = '[vue-test-utils]: overview() cannot be called on 0 items' | ||
|
||
expect(() => wrapper.findAll('p').overview()) | ||
.to.throw() | ||
.with.property('message', message) | ||
}) | ||
|
||
it('throws error when called on a WrapperArray', () => { | ||
const wrapper = mountingMethod(compileToFunctions('<div><div /></div>')) | ||
const message = | ||
'[vue-test-utils]: overview() must be called on a single wrapper, use at(i) to access a wrapper' | ||
|
||
expect(() => wrapper.findAll('div').overview()) | ||
.to.throw() | ||
.with.property('message', message) | ||
}) | ||
}) |
Oops, something went wrong.