From dc93e003d0fe17b9abb130f4e90ea2f504c231ed Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Wed, 6 Dec 2023 10:48:57 +0100 Subject: [PATCH] test: add failing test for `setProps` --- .../tests/nuxt/mount-suspended.spec.ts | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/examples/app-vitest-full/tests/nuxt/mount-suspended.spec.ts b/examples/app-vitest-full/tests/nuxt/mount-suspended.spec.ts index 20c630f37..f499ecc4a 100644 --- a/examples/app-vitest-full/tests/nuxt/mount-suspended.spec.ts +++ b/examples/app-vitest-full/tests/nuxt/mount-suspended.spec.ts @@ -1,4 +1,4 @@ -import { describe, expect, it } from 'vitest' +import { beforeEach, describe, expect, it } from 'vitest' import { mountSuspended } from '@nuxt/test-utils/runtime-utils' @@ -6,6 +6,7 @@ import App from '~/app.vue' import OptionsComponent from '~/components/OptionsComponent.vue' import WrapperTests from '~/components/WrapperTests.vue' +import type { VueWrapper} from '@vue/test-utils'; import { mount } from '@vue/test-utils' import ExportDefaultComponent from '~/components/ExportDefaultComponent.vue' @@ -110,15 +111,33 @@ describe('mountSuspended', () => { }) describe.each(Object.entries(formats))(`%s`, (name, component) => { - it('mounts with props', async () => { - const wrapper = await mountSuspended(component, { + let wrapper: VueWrapper + + beforeEach(async () => { + wrapper = await mountSuspended(component, { props: { myProp: 'Hello nuxt-vitest', }, }) + }) + + it('mounts with props', () => { expect(wrapper.html()).toEqual(`

${name}

Hello nuxt-vitest
XHello nuxt-vitest
+
+ `.trim()) + }) + + // FIXME: https://github.com/nuxt/test-utils/issues/534 + it.todo('can be updated with setProps', async () => { + wrapper.setProps({ + title: 'updated title' + }) + await nextTick() + expect(wrapper.html()).toEqual(` +
+

${name}

updated title
XHello nuxt-vitest
`.trim()) })