Tests using createLocalVue() display warning (rc.20)
See original GitHub issueDescribe the bug
Tests using bootstrap-vue
and createLocalVue()
output the following warning
[BootstrapVue warn]: Multiple instances of Vue detected!
See: https://bootstrap-vue.js.org/docs#using-module-bundlers
The test code looks like:
beforeEach(() => {
const localVue = createLocalVue();
localVue.use(BootstrapVue);
wrapper = mount(SomeComponent, { localVue });
});
Expected behavior
Tests run successfully without warnings.
Versions
Libraries:
bootstrap-vue
: 2.0.0-rc.20bootstrap
: 4.3.1vue
: 2.6.10jest
: 24.8.0vue-jest
: 3.0.4@vue/test-utils
: 1.0.0-beta.29
Environment:
Jest
Possible solution?!
The issue can be fixed by moving the localVue.use()
statement from the test file
beforeEach(() => {
const localVue = createLocalVue();
sectionPallet = mount(SectionPallet, { localVue });
});
to the jestSetup.js
.
import Vue from 'vue';
//...
Vue.use(BootstrapVue);
Now the tests run successfully. But the question is: Is that intended?
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (6 by maintainers)
Top Results From Across the Web
createLocalVue() - Vue Test Utils
createLocalVue returns a Vue class for you to add components, mixins and install plugins without polluting the global Vue class. The errorHandler option...
Read more >Chapter 10. Testing Vue Router
This chapter covers. Writing unit tests for components that use Vue Router properties; Writing unit tests for the RouterLink component; Using Vue ...
Read more >typeerror: cannot read properties of undefined ... - You.com
I'm new to unit tests and currently I'm using Jest with Vue2 Test Utils to create tests in a project already under development....
Read more >'Route with name 'something' does not exist' vue-router ...
I've created a Codepen (includes the whole file) of a page I was testing. It shows my basic setup and some ways I...
Read more >Vue.js and Vuetify unit testing with Jest - IOBIO
(The temperature is displayed in an alert component. ) Check the output. //tests/unit/DisplayTemperature.spec.js import { createLocalVue ...
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
Version 2.0.0-rc.21 has been released
The warnings should not cause tests to fail (but will place console warns in your test logs)
Adding the
Vue.use
injestSetup.js
would include the full library in each test, rather than testing for just the certain components in our test suites.You can disable BootstrapVue warns by setting
process.env.BOOTSTRAP_VUE_NO_WARN = true
before running your tests.https://bootstrap-vue.js.org/docs/misc/settings#disabling-bootstrapvue-console-warnings
You can also set up a console.warn mock to trap the warns (which we have done in some of our tests):