TypeError during importing Bootstrap-vue component to Jest test
See original GitHub issueDescribe the bug
Hey, I’ve wrapped BFormRadioGroup
and BFormCheckbox
with my custom components.
e.g. RadioInput.vue
:
<template>
<abc
:label="label"
data-input-type="radio"
>
<b-form-radio-group
:id="id"
v-model="currentValue"
:name="id"
:options="convertSelectOptions"
:stacked="convertDisplayStyle"
:disabled="disabled"
class="radio-input"
@input="updateInput()"
@click="propagateOnClick()"
></b-form-radio-group>
</abc>
</template>
and I want to write some unit tests in Jest (with typescript).
My simple Jest test to check if my custom component has BFormRadioGroup
in template:
import { BFormRadioGroup } from 'bootstrap-vue';
[...]
it('is wrapped by BFormRadioGroup', () => {
expect(wrapper.findComponent(BFormRadioGroup).exists())
.toBe(true);
});
After run test I’m getting error:
TypeError: Vue__default.default.extend is not a function
14 | import { BFormRadioGroup } from 'bootstrap-vue';
15 | ^
at Object.extend (node_modules/bootstrap-vue/dist/bootstrap-vue.common.js:1998:50)
at Object.<anonymous> (tests/unit/modules/shared/components/form/RadioInput.spec.ts:14:1)
I think there is a problem with importing anything from bootstrap-vue
, because it doesn’t even run the test.
Maybe do you have some idea what could be wrong? 😃
Greetings, Lucas
Versions
Libraries:
- BootstrapVue: 2.21.0
- Bootstrap: 4.5.3
- Vue: 2.6.12
- Jest: 23.0.0
Environment:
- Device: Linux
- OS: Mint
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Bootstrap-Vue throws TypeError in Jest - Stack Overflow
I'm using Bootstrap-Vue ^2.23.1 with Vuejs and vue/compat ^3.2.45 and my testing library is jest ^29.3.1 . But when I add the BootstrapVue...
Read more >BootstrapVue Unit Testing - Get Help - Vue Forum
Here's my test.js file, I'm testing the simplest component I can find. // import the mount method from test utils // and the...
Read more >Getting Started - BootstrapVue
Get started with BootstrapVue, based on the world's most popular framework ... You can import component groups and directives as Vue plugins by...
Read more >Test with Jest in Vue failing in child component because of ...
How to test for the existance of a bootstrap vue component in unit tests with jest? Test Vue with Jest fail, Jest encountered...
Read more >[vue warn]: error in render: "typeerror: cannot read properties ...
I am relatively new to Vue js and writing a test for a component which renders a ... import Vuex from 'vuex' import...
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
The same happened to me/us. Downgrading Bootstrap to
"bootstrap-vue": "2.17.3",
as a quick fix did the trick!Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please create a new issue with up-to-date information. Thank you!