Skip to content

Bug: Cannot stub out directive when mounting component? #2708

@MetRonnie

Description

@MetRonnie

Describe the bug

I have a component using Vuetify's v-tooltip directive.

<template>
  <span v-tooltip="'hover text'">Hover me</span>
</template>
const wrapper = mount(Component, {
  props,
  shallow: true,
  global: {
    directives: {
      tooltip: () => {},
    }
  }
})

When I try to shallow mount the component in a unit test I get an error

[Vuetify] Could not find defaults instance
[Vue warn]: injection "Symbol(vuetify:defaults)" not found.
at <VTooltip text="hover text" >
[Vue warn]: Component is missing template or render function: {
name: 'VTooltip',
...

Reproduction

https://stackblitz.com/edit/github-b2nobwpa?file=src%2Fcomponents%2F__tests__%2FHelloWorld.spec.ts&view=editor

Expected behavior

Stubbing the directive should work

Environment

System:
OS: Linux 5.0 undefined
CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Memory: 0 Bytes / 0 Bytes
Shell: 1.0 - /bin/jsh
npmPackages:
@vue/test-utils: ^2.4.6 => 2.4.6
vitest: ^3.2.4 => 3.2.4
vue: ^3.5.18 => 3.5.21

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions