-
Notifications
You must be signed in to change notification settings - Fork 669
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: export createWrapper method to create wrapper from instance (#868)
- Loading branch information
1 parent
c212ebf
commit ebca3b3
Showing
6 changed files
with
39 additions
and
2 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
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,19 @@ | ||
## createWrapper() | ||
|
||
- **Returns:** | ||
- `{Wrapper}` | ||
|
||
- **Usage:** | ||
|
||
`createWrapper` creates a `Wrapper` for a mounted Vue instance, or an HTML element. | ||
|
||
```js | ||
import { createWrapper } from '@vue/test-utils' | ||
import Foo from './Foo.vue' | ||
|
||
const Constructor = Vue.extend(Foo) | ||
const vm = new Constructor().$mount() | ||
const wrapper = createWrapper(vm) | ||
expect(wrapper.vm.foo).toBe(true) | ||
``` | ||
|
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,15 @@ | ||
import Vue from 'vue' | ||
import { createWrapper, Wrapper, WrapperArray } from '~vue/test-utils' | ||
import Component from '~resources/components/component.vue' | ||
import { describeRunIf } from 'conditional-specs' | ||
|
||
describeRunIf(process.env.TEST_ENV !== 'node', 'mount', () => { | ||
it.only('exports createWrapper', () => { | ||
const Constructor = Vue.extend(Component) | ||
const vm = new Constructor().$mount() | ||
const wrapper = createWrapper(vm) | ||
expect(wrapper.is(Component)).to.equal(true) | ||
expect(wrapper).instanceof(Wrapper) | ||
expect(wrapper.findAll('div')).instanceof(WrapperArray) | ||
}) | ||
}) |