question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Test fails for globally registered components

See original GitHub issue

Hey 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:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
ktsncommented, Feb 23, 2020

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 pure Vue.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/790

0reactions
MrWookcommented, Feb 24, 2020

For 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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found