-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API: Wrapper #22
base: working
Are you sure you want to change the base?
API: Wrapper #22
Changes from 2 commits
566e115
9b35b06
45969c4
7251209
3e77624
b3a594c
ad17e2e
7e77ee7
cf61c9f
91c5b21
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
# `Wrapper` | ||
|
||
<p><strong>⚠Cette page est actuellement en cours de traduction française. Vous pouvez repasser plus tard ou <a href="https://github.com/vuejs-fr/vue-test-utils" target="_blank">participer à la traduction</a> de celle-ci dès maintenant !</strong></p><p>Vue Test Utils is a wrapper based API.</p> | ||
`vue-test-utils` est une API basée sur un `wrapper`. | ||
|
||
A `Wrapper` is an object that contains a mounted component or vnode and methods to test the component or vnode. | ||
Un `Wrapper` est un objet qui contient un composant monté, un nœud virtuel et des méthodes pour les tester. | ||
|
||
- **Properties:** | ||
- **Propriétés :** | ||
|
||
`vm` `Component`: this is the `Vue` instance. You can access all the [instance methods and properties of a vm](https://vuejs.org/v2/api/#Instance-Properties) with `wrapper.vm`. This only exists on Vue component wrappers | ||
`element` `HTMLElement`: the root DOM node of the wrapper | ||
`options` `Object`: Object containing Vue Test Utils options passed to `mount` or `shallow` | ||
`options.attachedToDom` `Boolean`: True if `attachToDom` was passed to `mount` or `shallow` | ||
`vm` `Component`: c'est une instance de Vue. Vous pouvez accéder à toutes les [méthodes et propriétés de l'instance](https://vuejs.org/v2/api/#Instance-Properties) avec `wrapper.vm`. Cela existe uniquement sur les `wrappers` de composants Vue. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
`element` `HTMLElement`: le nœud principal du DOM du `wrapper`. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. le nœud |
||
`options` `Object`: objet contenant les options de `vue-test-utils` passées à `mount` ou `shallow`. | ||
`options.attachedToDom` `Boolean`: `true` si `attachToDom` est passé à `mount` ou `shallow`. | ||
|
||
- **Methods:** | ||
- **Méthodes :** | ||
|
||
There is a detailed list of methods in the wrapper section of the docs. | ||
Il y a une liste détaillé des méthodes dans la section `wrapper` de la documentation. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
# `emittedByOrder()` | ||
|
||
<p><strong>⚠Cette page est actuellement en cours de traduction française. Vous pouvez repasser plus tard ou <a href="https://github.com/vuejs-fr/vue-test-utils" target="_blank">participer à la traduction</a> de celle-ci dès maintenant !</strong></p><p>Return an Array containing custom events emitted by the `Wrapper` `vm`.</p> | ||
Retourne un tableau contenant des évènements émis par l'instance de Vue `vm` de `Wrapper`. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. contenant des évènements émis |
||
|
||
- **Returns:** `Array<{ name: string, args: Array<any> }>` | ||
- **Retourne :** `Array<{ name: string, args: Array<any> }>` | ||
|
||
- **Example:** | ||
- **Exemple :** | ||
|
||
```js | ||
import { mount } from '@vue/test-utils' | ||
|
@@ -15,13 +15,13 @@ wrapper.vm.$emit('foo') | |
wrapper.vm.$emit('bar', 123) | ||
|
||
/* | ||
wrapper.emittedByOrder() returns the following Array: | ||
wrapper.emittedByOrder() retourne le tableau suivant : | ||
[ | ||
{ name: 'foo', args: [] }, | ||
{ name: 'bar', args: [123] } | ||
] | ||
*/ | ||
|
||
// assert event emit order | ||
// asserte l'ordre des émissions | ||
expect(wrapper.emittedByOrder().map(e => e.name)).toEqual(['foo', 'bar']) | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
# `exists()` | ||
|
||
<p><strong>⚠Cette page est actuellement en cours de traduction française. Vous pouvez repasser plus tard ou <a href="https://github.com/vuejs-fr/vue-test-utils" target="_blank">participer à la traduction</a> de celle-ci dès maintenant !</strong></p><p>Assert `Wrapper` or `WrapperArray` exists.</p> | ||
Asserte que `Wrapper` ou `WrapperArray` existent. | ||
|
||
Returns false if called on an empty `Wrapper` or `WrapperArray`. | ||
Retourne `false` si appellé sur un `Wrapper` ou `WrapperArray` vide. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. appellé => appelé |
||
|
||
- **Returns:** `{boolean}` | ||
- **Retourne :** `{boolean}` | ||
|
||
- **Example:** | ||
- **Exemple :** | ||
|
||
```js | ||
import { mount } from '@vue/test-utils' | ||
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.find('existe-pas').exists()).toBe(false) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Attention, j'ai un doute sur cette traduction : j'ai peur que l'assertion ne fonctionne plus si on traduit 'does-not-exist' |
||
expect(wrapper.findAll('div').exists()).toBe(true) | ||
expect(wrapper.findAll('does-not-exist').exists()).toBe(false) | ||
expect(wrapper.findAll('existe-pas').exists()).toBe(false) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Attention, j'ai un doute sur cette traduction : j'ai peur que l'assertion ne fonctionne plus si on traduit 'does-not-exist' |
||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
# `name()` | ||
|
||
<p><strong>⚠Cette page est actuellement en cours de traduction française. Vous pouvez repasser plus tard ou <a href="https://github.com/vuejs-fr/vue-test-utils" target="_blank">participer à la traduction</a> de celle-ci dès maintenant !</strong></p><p>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.</p> | ||
Retourne le nom du composant si le `Wrapper` contient une instance de Vue. Il retourne le nom de la balise du nœud du DOM du `Wrapper` si il ne contient pas une instance de Vue. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. si il ne contient pas une instance de Vue. |
||
|
||
- **Returns:** `{string}` | ||
- **Retourne :** `{string}` | ||
|
||
- **Example:** | ||
- **Exemple :** | ||
|
||
```js | ||
import { mount } from '@vue/test-utils' | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Un
Wrapper
est un objet qui contient un composant monté, un nœud virtuel et des méthodes pour les tester.=>
Un
Wrapper
est un objet qui contient un composant monté ou un nœud virtuel et des méthodes pour les tester.