Skip to content

Commit dc93e00

Browse files
committed
test: add failing test for setProps
1 parent 84d67f1 commit dc93e00

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

examples/app-vitest-full/tests/nuxt/mount-suspended.spec.ts

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import { describe, expect, it } from 'vitest'
1+
import { beforeEach, describe, expect, it } from 'vitest'
22

33
import { mountSuspended } from '@nuxt/test-utils/runtime-utils'
44

55
import App from '~/app.vue'
66
import OptionsComponent from '~/components/OptionsComponent.vue'
77
import WrapperTests from '~/components/WrapperTests.vue'
88

9+
import type { VueWrapper} from '@vue/test-utils';
910
import { mount } from '@vue/test-utils'
1011

1112
import ExportDefaultComponent from '~/components/ExportDefaultComponent.vue'
@@ -110,15 +111,33 @@ describe('mountSuspended', () => {
110111
})
111112

112113
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, {
115118
props: {
116119
myProp: 'Hello nuxt-vitest',
117120
},
118121
})
122+
})
123+
124+
it('mounts with props', () => {
119125
expect(wrapper.html()).toEqual(`
120126
<div>
121127
<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>
122141
</div>
123142
`.trim())
124143
})

0 commit comments

Comments
 (0)