Test fails for globally registered components
See original GitHub issueHey i found a bug that is related to unit tests. I don’t really know if this is the right place but to post a vue related bug into the ts-jest repo seems kinda strange.
Situation:
I have a component A
that is using a globally registered component B
.
Component A
is loaded async into the app.
Problem:
If component A
is written in typescript with vue-class-component
and is loaded async, a jest test can’t find the globally registered component B
.
If component A
is written without typescript it will work perfectly fine.
Here is a reproduction setup with vue-cli: https://github.com/MrWook/ts-jest-bug
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Test fails for globally registered components #1448 - GitHub
Problem: If component A is written with Vue.extend for example with vue-class-component(typescript) and is loaded async, a jest test can't find ...
Read more >Can't register component globally VUE 3 - Stack Overflow
In UI/index.js try to export an array [] not an object {} : import MyButton from "@/components/UI/MyButton"; export default [ MyButton, ];.
Read more >Vue Global Registered Component give error as Unknown ...
Hi I just started to implement testing in my frontend, it looks that everything works almost fine. The default test that the template...
Read more >How to register global components in Vue 3 dynamically?
Vue 3 already has a documentation about registering components globally. Global components are Vue components that can be declared ...
Read more >Guides | Vue Test Utils
You can override components that are registered globally or locally by using the stubs option: import { mount } from '@vue/test-utils' mount(Component, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Well,
stubs
of vue-test-utils is not a global registration. In any cases, this is not a vue-class-component issue as this can be reproduced without it. I confirmed testing failure after rewriting vue-class-component with pureVue.extend
.I’m not sure about the implementation of vue-testing-library but this is likely vue-testing-library issue as I saw similar one in vue-test-utils which the cause was referring different
Vue
constructors between the root and the target component. You may want to file an issue to vue-testing-library. https://github.com/vuejs/vue-test-utils/issues/790For documentation reason here is the link for my new issue. Seems like that vue-test-utils is the correct repository to adress this issue https://github.com/vuejs/vue-test-utils/issues/1448