-
Notifications
You must be signed in to change notification settings - Fork 668
docs: Russian translation moved to VuePress #703
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
Changes from 18 commits
8210198
ecebea9
88f2232
41142a2
357aed6
87bd777
e73a1f3
5c8acab
2393f2d
6b49f1f
fab22dd
4b6aa47
4223d08
3a83e0c
c6f0f06
bce0f19
7559dff
7591e24
b0b27bf
500867b
6bb0c61
0a52a7c
00a8f94
7f5b7c8
06fe6d8
b00ef25
658e7f7
8344ff5
cd6247d
065f3a4
9b9da48
935f71c
c20a7cd
1caef3f
d79cee4
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 |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# Введение | ||
|
||
`vue-test-utils` — официальная библиотека модульного тестирования для Vue.js. | ||
|
||
* [Руководства](guides/) | ||
* [Введение](guides/getting-started.md) | ||
* [Общие советы](guides/common-tips.md) | ||
* [Мышь, клавиши и другие события DOM](guides/dom-events.md) | ||
* [Чем запускать тесты](guides/choosing-a-test-runner.md) | ||
* [Тестирование однофайловых компонентов с Jest](guides/testing-SFCs-with-jest.md) | ||
* [Тестирование однофайловых компонентов с Mocha + webpack](guides/testing-SFCs-with-mocha-webpack.md) | ||
* [Testing однофайловых компонентов с Karma](guides/testing-SFCs-with-karma.md) | ||
* [Тестирование асинхронной логики](guides/testing-async-components.md) | ||
* [Использование с Vue Router](guides/using-with-vue-router.md) | ||
* [Использование с Vuex](guides/using-with-vuex.md) | ||
* [API](api/) | ||
* [mount](api/mount.md) | ||
* [shallowMount](api/shallowMount.md) | ||
* [render](api/render.md) | ||
* [renderToString](api/renderToString.md) | ||
* [Опции монтирования](api/options.md) | ||
- [context](api/options.md#context) | ||
- [slots](api/options.md#slots) | ||
- [scopedSlots](api/options.md#scopedslots) | ||
- [stubs](api/options.md#stubs) | ||
- [mocks](api/options.md#mocks) | ||
- [localVue](api/options.md#localvue) | ||
- [attachToDocument](api/options.md#attachtodocument) | ||
- [attrs](api/options.md#attrs) | ||
- [listeners](api/options.md#listeners) | ||
- [provide](api/options.md#provide) | ||
- [sync](api/options.md#sync) | ||
- [другие опции](api/options.md#other-options) | ||
* [Wrapper](api/wrapper/) | ||
* [attributes](api/wrapper/attributes.md) | ||
* [classes](api/wrapper/classes.md) | ||
* [contains](api/wrapper/contains.md) | ||
* [emitted](api/wrapper/emitted.md) | ||
* [emittedByOrder](api/wrapper/emittedByOrder.md) | ||
* [exists](api/wrapper/exists.md) | ||
* [destroy](api/wrapper/destroy.md) | ||
* [find](api/wrapper/find.md) | ||
* [findAll](api/wrapper/findAll.md) | ||
* [html](api/wrapper/html.md) | ||
* [is](api/wrapper/is.md) | ||
* [isEmpty](api/wrapper/isEmpty.md) | ||
* [isVueInstance](api/wrapper/isVueInstance.md) | ||
* [name](api/wrapper/name.md) | ||
* [props](api/wrapper/props.md) | ||
* [setChecked](api/wrapper/setChecked.md) | ||
* [setData](api/wrapper/setData.md) | ||
* [setMethods](api/wrapper/setMethods.md) | ||
* [setProps](api/wrapper/setProps.md) | ||
* [setSelected](api/wrapper/setSelected.md) | ||
* [setValue](api/wrapper/setValue.md) | ||
* [text](api/wrapper/text.md) | ||
* [trigger](api/wrapper/trigger.md) | ||
* [isVisible](api/wrapper/isVisible.md) | ||
* [WrapperArray](api/wrapper-array/) | ||
* [at](api/wrapper-array/at.md) | ||
* [contains](api/wrapper-array/contains.md) | ||
* [exists](api/wrapper/exists.md) | ||
* [destroy](api/wrapper-array/destroy.md) | ||
* [filter](api/wrapper-array/filter.md) | ||
* [is](api/wrapper-array/is.md) | ||
* [isEmpty](api/wrapper-array/isEmpty.md) | ||
* [isVueInstance](api/wrapper-array/isVueInstance.md) | ||
* [setData](api/wrapper-array/setData.md) | ||
* [setMethods](api/wrapper-array/setMethods.md) | ||
* [setProps](api/wrapper-array/setProps.md) | ||
* [trigger](api/wrapper-array/trigger.md) | ||
* [isVisible](api/wrapper-array/isVisible.md) | ||
* [Компоненты](api/components/) | ||
* [TransitionStub](api/components/TransitionStub.md) | ||
* [TransitionGroupStub](api/components/TransitionGroupStub.md) | ||
* [RouterLinkStub](api/components/RouterLinkStub.md) | ||
* [Селекторы](api/selectors.md) | ||
* [createLocalVue](api/createLocalVue.md) | ||
* [Конфигурация](api/config.md) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# API | ||
|
||
!!!include(docs/ru/api/mount.md)!!! | ||
!!!include(docs/ru/api/shallowMount.md)!!! | ||
!!!include(docs/ru/api/render.md)!!! | ||
!!!include(docs/ru/api/renderToString.md)!!! | ||
!!!include(docs/ru/api/selectors.md)!!! | ||
!!!include(docs/ru/api/createLocalVue.md)!!! | ||
!!!include(docs/ru/api/config.md)!!! |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Компоненты | ||
|
||
Vue Test Utils включает утилиты, которые вы можете использовать для создания заглушек компонентов. | ||
|
||
!!!include(docs/ru/api/components/RouterLinkStub.md)!!! | ||
!!!include(docs/ru/api/components/TransitionStub.md)!!! | ||
!!!include(docs/ru/api/components/TransitionGroupStub.md)!!! |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
## RouterLinkStub | ||
|
||
Компонент для заглушки компонента Vue Router `router-link`. | ||
|
||
Вы можете использовать этот компонент для поиска компонента router-link в дереве рендеринга. | ||
|
||
- **Использование:** | ||
|
||
Чтобы установить его как заглушку в опциях монтирования: | ||
|
||
```js | ||
import { mount, RouterLinkStub } from '@vue/test-utils' | ||
|
||
const wrapper = mount(Component, { | ||
stubs: { | ||
RouterLink: RouterLinkStub | ||
} | ||
}) | ||
expect(wrapper.find(RouterLinkStub).props().to).toBe('/some/path') | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
## TransitionGroupStub | ||
|
||
Компонент для создания заглушки компонента `transition-group`. Вместо асинхронного выполнения переходов он возвращает дочерние компоненты синхронно. | ||
|
||
Это настроено на заглушку всех компонентов `transition-group` по умолчанию в конфигурации vue-test-utils. Чтобы использовать стандартный компонент `transition-group` установите `config.stubs['transition-group']` в значение false: | ||
|
||
```js | ||
import { config } from '@vue/test-utils' | ||
|
||
config.stubs['transition-group'] = false | ||
``` | ||
|
||
Чтобы переустановить обратно на заглушки компонентов `transition-group`: | ||
|
||
```js | ||
import { config, TransitionGroupStub } from '@vue/test-utils' | ||
|
||
config.stubs['transition-group'] = TransitionGroupStub | ||
``` | ||
|
||
Для установки заглушек в настройках монтирования: | ||
|
||
```js | ||
import { mount, TransitionGroupStub } from '@vue/test-utils' | ||
|
||
mount(Component, { | ||
stubs: { | ||
'transition-group': TransitionGroupStub | ||
} | ||
}) | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
## TransitionStub | ||
|
||
Компонент для создания заглушки компонента `transition`. Вместо асинхронного выполнения переходов он возвращает дочерний компонент синхронно. | ||
|
||
Это настроено на заглушку всех компонентов `transition` по умолчанию в конфигурации vue-test-utils. Чтобы использовать стандартный компонент `transition` установите `config.stubs.transition` в значение false: | ||
|
||
```js | ||
import { config } from '@vue/test-utils' | ||
|
||
config.stubs.transition = false | ||
``` | ||
|
||
Чтобы переустановить обратно на заглушки компонентов `transition`: | ||
```js | ||
import { config, TransitionStub } from '@vue/test-utils' | ||
|
||
config.stubs.transition = TransitionStub | ||
``` | ||
|
||
Для установки заглушек в настройках монтирования: | ||
|
||
```js | ||
import { mount, TransitionStub } from '@vue/test-utils' | ||
|
||
mount(Component, { | ||
stubs: { | ||
transition: TransitionStub | ||
} | ||
}) | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
## Конфигурация | ||
|
||
Vue Test Utils включает объект конфигурации для определения опций, используемых Vue Test Utils. | ||
|
||
### Конфигурация настроек Vue Test Utils | ||
|
||
### `stubs` | ||
|
||
- Тип: `Object` | ||
- По умолчанию: `{ | ||
transition: TransitionStub, | ||
'transition-group': TransitionGroupStub | ||
}` | ||
|
||
Заглушки указанные в `config.stubs` используются по умолчанию. | ||
Заглушки, используемые в компонентах. Они перезаписываются значениями `stubs` переданными в настройках монтирования. | ||
|
||
При передаче `stubs` в качестве массива в настройках монтирования, `config.stubs` будет преобразована в массив, и будут создаваться компоненты заглушки с базовым компонентом, который возвращает div. | ||
|
||
Пример: | ||
|
||
```js | ||
import VueTestUtils from '@vue/test-utils' | ||
|
||
VueTestUtils.config.stubs['my-component'] = '<div />' | ||
``` | ||
|
||
### `mocks` | ||
|
||
- type: `Object` | ||
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. type -> Тип |
||
- default: `{}` | ||
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. default -> по умолчанию |
||
|
||
По аналогии с `stubs`, значения, переданные в `config.mocks` используются по умолчанию. Любые значения, переданные настройкам монтирования объекта `mocks`, будут иметь приоритет выше, по сравнению с объявленными в `config.mocks`. | ||
|
||
Пример: | ||
|
||
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. Example -> Пример |
||
```js | ||
import VueTestUtils from '@vue/test-utils' | ||
|
||
VueTestUtils.config.mocks['$store'] = { | ||
state: { | ||
id: 1 | ||
} | ||
} | ||
``` | ||
|
||
### `methods` | ||
|
||
- type: `Object` | ||
- default: `{}` | ||
|
||
Вы можете настроить методы по умолчанию с помощью объекта `config`. Это может быть полезно для плагинов, которые вводят методы в компоненты, такие как [VeeValidate](https://vee-validate.logaretm.com/). Вы можете переопределить методы, установленные в `config`, передав `methods` в настройках монтирования. | ||
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. Also need change link to https://baianat.github.io/vee-validate/ |
||
|
||
Пример: | ||
|
||
```js | ||
import VueTestUtils from '@vue/test-utils' | ||
|
||
VueTestUtils.config.methods['errors'] = () => { | ||
any: () => false | ||
} | ||
``` | ||
|
||
### `provide` | ||
|
||
- type: `Object` | ||
- default: `{}` | ||
|
||
Как `stubs` или `mocks`, значения, переданные `config.provide`, используются по умолчанию. Любые значения, переданные настройкам монтирования объекта `provide`, будут иметь приоритет выше по сравнению с объявленными в `config.provide`. **Обратите внимание, что не поддерживается передача функции в качестве `config.provide`.** | ||
|
||
Пример: | ||
|
||
```js | ||
import VueTestUtils from '@vue/test-utils' | ||
|
||
VueTestUtils.config.provide['$logger'] = { | ||
log: (...args) => { | ||
console.log(...args) | ||
} | ||
} | ||
``` | ||
|
||
### `logModifiedComponents` | ||
|
||
- type: `Boolean` | ||
- default: `true` | ||
|
||
Логирует о предупреждениях, когда для расширенных дочерних компонентов автоматически создаётся заглушка. Скрывает предупреждения, когда установлено значение `false`. В отличие от других опций конфигурации, это невозможно установить в настройках монтирования. | ||
|
||
Пример: | ||
|
||
```js | ||
import VueTestUtils from '@vue/test-utils' | ||
|
||
VueTestUtils.config.logModifiedComponents = false | ||
``` | ||
|
||
### `silentWarnings` | ||
|
||
- type: `Boolean` | ||
- default: `true` | ||
|
||
Подавляет предупреждения, вызванные Vue во время изменения наблюдаемых компонентов (например, входных параметров). Если установлено значение `false`, все предупреждения показываются в консоли. Это настраиваемый способ, который основывается на `Vue.config.silent`. | ||
|
||
Пример: | ||
|
||
```js | ||
import VueTestUtils from '@vue/test-utils' | ||
|
||
VueTestUtils.config.silentWarnings = false | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
## createLocalVue() | ||
|
||
- **Возвращает:** | ||
- `{Component}` | ||
|
||
- **Использование:** | ||
|
||
`createLocalVue` возвращает класс Vue, чтобы вы могли добавлять компоненты, примеси и устанавливать плагины без загрузнения глобального класса Vue. | ||
|
||
Используйте вместе с `options.localVue`: | ||
|
||
```js | ||
import { createLocalVue, shallowMount } from '@vue/test-utils' | ||
import Foo from './Foo.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. shallow -> shallowMount 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. @38elements thank you! I have not everywhere before made a replacement, now thanks to you, I replaced everywhere with |
||
|
||
const localVue = createLocalVue() | ||
const wrapper = shallowMount(Foo, { | ||
localVue, | ||
mocks: { foo: true } | ||
}) | ||
expect(wrapper.vm.foo).toBe(true) | ||
|
||
const freshWrapper = shallowMount(Foo) | ||
expect(freshWrapper.vm.foo).toBe(false) | ||
``` | ||
|
||
- **См. также:** [Общие советы](../guides/common-tips.md#applying-global-plugins-and-mixins) |
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.
div -> <${component name}-stub>
https://vue-test-utils.vuejs.org/api/config.html#stubs