Cannot set config on localVue
See original GitHub issueVersion
1.0.0-beta.12
Reproduction link
https://codesandbox.io/s/ovx3l48j3y
Steps to reproduce
- create a localVue and set an empty warn handler
const silentVue = createLocalVue();
silentVue.config.warnHandler = () => {};
- Write a test that should not show warnings. In my case I don’t want this test show validation errors, cause I am testing that the correct props are being passed to child component
test.only('computeds are passed as props', () => {
const wrapper = shallow(App, {
computed: {
computedOne: () => 'COMPUTED ONE',
computedTwo: () => 'COMPUTED TWO',
},
localVue: silentVue,
});
const component = wrapper.find(ChildComponent);
expect(component.props()).toEqual({
foo: 'COMPUTED ONE',
bar: 'COMPUTED TWO',
});
});
What is expected?
Disable warnings for this específic test
What is actually happening?
Showing warnings in console
Vue.config.warnHandler = () => {};
works but I want to avoid this in other tests
Issue Analytics
- State:
- Created 5 years ago
- Comments:11 (3 by maintainers)
Top Results From Across the Web
Vue testing: shallowMount & localVue produce error on ...
This one drove me up the wall but I managed to isolate the problem and find two distinct workarounds. The first was to...
Read more >Mounting Options | Vue Test Utils
Provide an object of scoped slots to the component. The key corresponds to the slot name. You can set the name of the...
Read more >Things You Might Not Know About Vue-Test-Utils - WebDevEtc
If you have used the localVue.use(VueRouter) and then use that when mounting, you will not be able to set mocked route data.
Read more >Unit Testing a Vue Component with Vuex Using Vue Test Utils ...
Firstly we create our localVue instance with BootstrapVue (for rendering b-form-input, ... I mean, a test can not affect the other one.
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 >
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 Free
Top 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
Waking this old thread for a slightly different reason than the original.
Since converting to Vitest I get bombarded with “Download the Vue Devtools extension for a better development experience:” and “You are running Vue in development mode.” warning. I haven’t figured out how to disable these.
It would be great if we could set the config on the localVue object or expose some kind of “setup” function where we can access a reference to the original Vue constructor. One idea is that
createLocalVue
can accept a callback that exposes the ubnderlying Vue object.I can see why you’re confused now. Setting anything in the config of a localVue does not affect the code, because the code still uses the base Vue class config object. I’m not sure what we can do about this, because the config object is set once you require Vue, or once we require Vue in createLocalVue.
Perhaps we could add a setter that warns that setting config on a localVue will not have the desired affect.