|
1 | | -import { describe, expect, it } from 'vitest' |
| 1 | +import { beforeEach, describe, expect, it } from 'vitest' |
2 | 2 |
|
3 | 3 | import { mountSuspended } from '@nuxt/test-utils/runtime-utils' |
4 | 4 |
|
5 | 5 | import App from '~/app.vue' |
6 | 6 | import OptionsComponent from '~/components/OptionsComponent.vue' |
7 | 7 | import WrapperTests from '~/components/WrapperTests.vue' |
8 | 8 |
|
| 9 | +import type { VueWrapper} from '@vue/test-utils'; |
9 | 10 | import { mount } from '@vue/test-utils' |
10 | 11 |
|
11 | 12 | import ExportDefaultComponent from '~/components/ExportDefaultComponent.vue' |
@@ -110,15 +111,33 @@ describe('mountSuspended', () => { |
110 | 111 | }) |
111 | 112 |
|
112 | 113 | describe.each(Object.entries(formats))(`%s`, (name, component) => { |
113 | | - it('mounts with props', async () => { |
114 | | - const wrapper = await mountSuspended(component, { |
| 114 | + let wrapper: VueWrapper<any> |
| 115 | + |
| 116 | + beforeEach(async () => { |
| 117 | + wrapper = await mountSuspended(component, { |
115 | 118 | props: { |
116 | 119 | myProp: 'Hello nuxt-vitest', |
117 | 120 | }, |
118 | 121 | }) |
| 122 | + }) |
| 123 | + |
| 124 | + it('mounts with props', () => { |
119 | 125 | expect(wrapper.html()).toEqual(` |
120 | 126 | <div> |
121 | 127 | <h1>${name}</h1><pre>Hello nuxt-vitest</pre><pre>XHello nuxt-vitest</pre> |
| 128 | +</div> |
| 129 | + `.trim()) |
| 130 | + }) |
| 131 | + |
| 132 | + // FIXME: https://github.com/nuxt/test-utils/issues/534 |
| 133 | + it.todo('can be updated with setProps', async () => { |
| 134 | + wrapper.setProps({ |
| 135 | + title: 'updated title' |
| 136 | + }) |
| 137 | + await nextTick() |
| 138 | + expect(wrapper.html()).toEqual(` |
| 139 | +<div> |
| 140 | + <h1>${name}</h1><pre>updated title</pre><pre>XHello nuxt-vitest</pre> |
122 | 141 | </div> |
123 | 142 | `.trim()) |
124 | 143 | }) |
|
0 commit comments