1
- import { Component , ComponentOptions , Directive , Plugin , AppConfig } from 'vue'
1
+ import {
2
+ Component ,
3
+ ComponentOptions ,
4
+ Directive ,
5
+ Plugin ,
6
+ AppConfig ,
7
+ VNode
8
+ } from 'vue'
2
9
3
10
interface RefSelector {
4
11
ref : string
@@ -19,14 +26,108 @@ interface NameSelector {
19
26
export type FindComponentSelector = RefSelector | NameSelector | string
20
27
export type FindAllComponentsSelector = NameSelector | string
21
28
29
+ export type Slot = VNode | string | { render : Function } | Function | Component
30
+
31
+ type SlotDictionary = {
32
+ [ key : string ] : Slot
33
+ }
34
+
35
+ export interface MountingOptions < Props , Data = { } > {
36
+ /**
37
+ * Overrides component's default data. Must be a function.
38
+ * @see https://vue-test-utils.vuejs.org/v2/api/#data
39
+ */
40
+ data ?: ( ) => { } extends Data ? any : Data extends object ? Partial < Data > : any
41
+ /**
42
+ * Sets component props when mounted.
43
+ * @see https://vue-test-utils.vuejs.org/v2/api/#props
44
+ */
45
+ props ?: Props
46
+ /**
47
+ * @deprecated use `data` instead.
48
+ */
49
+ propsData ?: Props
50
+ /**
51
+ * Sets component attributes when mounted.
52
+ * @see https://vue-test-utils.vuejs.org/v2/api/#attrs
53
+ */
54
+ attrs ?: Record < string , unknown >
55
+ /**
56
+ * Provide values for slots on a component. Slots can be a component
57
+ * imported from a .vue file or a render function. Providing an
58
+ * object with a `template` key is not supported.
59
+ * @see https://vue-test-utils.vuejs.org/v2/api/#slots
60
+ */
61
+ slots ?: SlotDictionary & {
62
+ default ?: Slot
63
+ }
64
+ /**
65
+ * Provides global mounting options to the component.
66
+ */
67
+ global ?: GlobalMountOptions
68
+ /**
69
+ * Specify where to mount the component.
70
+ * Can be a valid CSS selector, or an Element connected to the document.
71
+ * @see https://vue-test-utils.vuejs.org/v2/api/#attachto
72
+ */
73
+ attachTo ?: HTMLElement | string
74
+ /**
75
+ * Automatically stub out all the child components.
76
+ * @default false
77
+ * @see https://vue-test-utils.vuejs.org/v2/api/#slots
78
+ */
79
+ shallow ?: boolean
80
+ }
81
+
22
82
export type GlobalMountOptions = {
83
+ /**
84
+ * Installs plugins on the component.
85
+ * @see https://vue-test-utils.vuejs.org/v2/api/#plugins
86
+ */
23
87
plugins ?: ( Plugin | [ Plugin , ...any [ ] ] ) [ ]
88
+ /**
89
+ * Customizes Vue application global configuration
90
+ * @see https://v3.vuejs.org/api/application-config.html#application-config
91
+ */
24
92
config ?: Partial < Omit < AppConfig , 'isNativeTag' > > // isNativeTag is readonly, so we omit it
93
+ /**
94
+ * Applies a mixin for components under testing.
95
+ * @see https://vue-test-utils.vuejs.org/v2/api/#mixins
96
+ */
25
97
mixins ?: ComponentOptions [ ]
98
+ /**
99
+ * Mocks a global instance property.
100
+ * This is designed to mock variables injected by third party plugins, not
101
+ * Vue's native properties such as $root, $children, etc.
102
+ * @see https://vue-test-utils.vuejs.org/v2/api/#mocks
103
+ */
26
104
mocks ?: Record < string , any >
105
+ /**
106
+ * Provides data to be received in a setup function via `inject`.
107
+ * @see https://vue-test-utils.vuejs.org/v2/api/#provide
108
+ */
27
109
provide ?: Record < any , any >
110
+ /**
111
+ * Registers components globally for components under testing.
112
+ * @see https://vue-test-utils.vuejs.org/v2/api/#components
113
+ */
28
114
components ?: Record < string , Component | object >
115
+ /**
116
+ * Registers a directive globally for components under testing
117
+ * @see https://vue-test-utils.vuejs.org/v2/api/#directives
118
+ */
29
119
directives ?: Record < string , Directive >
120
+ /**
121
+ * Stubs a component for components under testing.
122
+ * @default "{ transition: true, 'transition-group': true }"
123
+ * @see https://vue-test-utils.vuejs.org/v2/api/#global-stubs
124
+ */
30
125
stubs ?: Record < any , any >
126
+ /**
127
+ * Allows rendering the default slot content, even when using
128
+ * `shallow` or `shallowMount`.
129
+ * @default false
130
+ * @see https://vue-test-utils.vuejs.org/v2/api/#renderstubdefaultslot
131
+ */
31
132
renderStubDefaultSlot ?: boolean
32
133
}
0 commit comments