Skip to content

Bug: is config.global.components ignored by testing-lib?  #279

Open
@jonsalvas

Description

@jonsalvas

Describe the bug A clear and concise description of what the bug is.
According to the vue-test-utils documentation it is possible to register global stuff using config.global.*, so for instance with config.global.components = { HelloWorldComponent } you can make that component globally available. This works fine when using mount() from test-utils but fails when using render() from vue-testing-library (that is why I posted the bug here). Error message is such as:

[Vue warn]: Failed to resolve component: HelloWorldComponent
If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement. 
  at <ParentComponent ref="VTU_COMPONENT" > 
  at <VTUROOT>

When adding the component directly to the global in the render() function it works, but not when setting it globally via config.global.

If this is intended that testing-library can only add the globals to the render function, it would mean I have to add the same global for every test (we have 300 tests right now). Then consider this as a feature request :-)

To Reproduce Steps to reproduce the behavior:
Here is a small reproduction project:
https://github.com/jonsalvas/testinglib-reproduce-config-global-issue

Expected behavior

All stuff registered using config.global is globally available in all components.

Screenshots

Related information:

  • @testing-library/vue version: 6.5.1
  • Vue version: 3.2.25
  • node version: 17.8.0
  • npm (or yarn) version: 8.5.5

Relevant code or config (if any)

see reproduction project

Additional context

Initially I encountered the issue when upgrading @vue/test-utils from 2.0.0-rc.17 to 2.0.0-rc.21 so I was sure it was related to that. However when downgrading I was unable to make it work again. I assume my project was broken somehow.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions