13
13
- ` {Object|Array<string>} stubs `
14
14
- ` {Vue} localVue `
15
15
16
- - ** Возвращает:** ` {string} `
16
+ - ** Возвращает:** ` {Promise< string> } `
17
17
18
18
- ** Опции:**
19
19
@@ -34,9 +34,9 @@ import { renderToString } from '@vue/server-test-utils'
34
34
import Foo from ' ./Foo.vue'
35
35
36
36
describe (' Foo' , () => {
37
- it (' renders a div' , () => {
38
- const renderedString = renderToString (Foo)
39
- expect (renderedString ).toContain (' <div></div>' )
37
+ it (' renders a div' , async () => {
38
+ const str = await renderToString (Foo)
39
+ expect (str ).toContain (' <div></div>' )
40
40
})
41
41
})
42
42
```
@@ -48,13 +48,13 @@ import { renderToString } from '@vue/server-test-utils'
48
48
import Foo from ' ./Foo.vue'
49
49
50
50
describe (' Foo' , () => {
51
- it (' renders a div' , () => {
52
- const renderedString = renderToString (Foo, {
51
+ it (' renders a div' , async () => {
52
+ const str = await renderToString (Foo, {
53
53
propsData: {
54
54
color: ' red'
55
55
}
56
56
})
57
- expect (renderedString ).toContain (' red' )
57
+ expect (str ).toContain (' red' )
58
58
})
59
59
})
60
60
```
@@ -68,15 +68,15 @@ import Bar from './Bar.vue'
68
68
import FooBar from ' ./FooBar.vue'
69
69
70
70
describe (' Foo' , () => {
71
- it (' renders a div' , () => {
72
- const renderedString = renderToString (Foo, {
71
+ it (' renders a div' , async () => {
72
+ const str = await renderToString (Foo, {
73
73
slots: {
74
74
default: [Bar, FooBar],
75
75
fooBar: FooBar, // Будет соответствовать <slot name="FooBar" />,
76
76
foo: ' <div />'
77
77
}
78
78
})
79
- expect (renderedString ).toContain (' <div></div>' )
79
+ expect (str ).toContain (' <div></div>' )
80
80
})
81
81
})
82
82
```
@@ -88,14 +88,14 @@ import { renderToString } from '@vue/server-test-utils'
88
88
import Foo from ' ./Foo.vue'
89
89
90
90
describe (' Foo' , () => {
91
- it (' renders a div' , () => {
91
+ it (' renders a div' , async () => {
92
92
const $route = { path: ' http://www.example-path.com' }
93
- const renderedString = renderToString (Foo, {
93
+ const str = await renderToString (Foo, {
94
94
mocks: {
95
95
$route
96
96
}
97
97
})
98
- expect (renderedString ).toContain ($route .path )
98
+ expect (str ).toContain ($route .path )
99
99
})
100
100
})
101
101
```
0 commit comments