Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions examples/app-vitest-full/components/DirectiveComponent.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<template>
<div v-sample-directive />
</template>
7 changes: 7 additions & 0 deletions examples/app-vitest-full/plugins/directive.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.vueApp.directive('sample-directive', {
created(el: Element) {
el.setAttribute('data-directive', 'true')
},
})
})
6 changes: 6 additions & 0 deletions examples/app-vitest-full/tests/nuxt/mount-suspended.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import ExportDefaultWithRenderComponent from '~/components/ExportDefaultWithRend
import ExportDefaultReturnsRenderComponent from '~/components/ExportDefaultReturnsRenderComponent.vue'

import { BoundAttrs } from '#components'
import DirectiveComponent from '~/components/DirectiveComponent.vue'

const formats = {
ExportDefaultComponent,
Expand Down Expand Up @@ -117,6 +118,11 @@ describe('mountSuspended', () => {
// @ts-expect-error FIXME: someRef is typed as unwrapped
expect(component.vm.someRef.value).toBe('thing')
})

it('respects directives registered in nuxt plugins', async () => {
const component = await mountSuspended(DirectiveComponent)
expect(component.html()).toMatchInlineSnapshot(`"<div data-directive="true"></div>"`)
})
})

describe.each(Object.entries(formats))(`%s`, (name, component) => {
Expand Down
1 change: 1 addition & 0 deletions src/runtime-utils/mount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ export async function mountSuspended<T>(
config: {
globalProperties: vueApp.config.globalProperties,
},
directives: vueApp._context.directives,
provide: vueApp._context.provides,
stubs: {
Suspense: false,
Expand Down