Skip to content

Bug: Using of plugins is impossible #2008

@jimhucksly

Description

@jimhucksly

Describe the bug

To Reproduce
plugin.ts

import { App } from 'vue'

export default {
  install: (vue: App) => {
    const method = () => {
      ...
    }
    vue.config.globalProperties.$method = method
  }
}

component.vue

<template>
  <p>Vue Component</p>
</template>

test.spec.ts

import { mount, VueWrapper } from '@vue/test-utils'
import plugin from './plugin.js'
import component from './component.vue'

let wrapper: VueWrapper<Vue> = null
let component: Vue = null

async function setupTest() {
  wrapper = mount(component, {
    global: {
      plugins: [plugin]
    }
  })
  component = wrapper.vm
}

describe('App', () => {
  beforeEach(async () => {
    await setupTest()
  });

  it('router is ready', async () => {
    expect(component.$method).toBeDefined() // false
  })
})

**Expected behavior**
expect(component.$method).toBeDefined() // true

**Related information:**
  System:
    OS: Windows 10 10.0.19044
    CPU: (12) x64 Intel(R) Core(TM) i5-10600 CPU @ 3.30GHz
    Memory: 8.21 GB / 15.62 GB
  npmPackages:
    @vue/test-utils: ^2.3.1 => 2.3.1
    jest: ^26.6.3 => 26.6.3
    vue: ^3.2.20 => 3.2.20>

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions