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.

TypeError during importing Bootstrap-vue component to Jest test

See original GitHub issue

Describe 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:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
Wittmaxicommented, Jan 28, 2021

The same happened to me/us. Downgrading Bootstrap to "bootstrap-vue": "2.17.3", as a quick fix did the trick!

0reactions
stale[bot]commented, Jun 22, 2021

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!

Read more comments on GitHub >

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

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