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.

Cannot set config on localVue

See original GitHub issue

Version

1.0.0-beta.12

Reproduction link

https://codesandbox.io/s/ovx3l48j3y

Steps to reproduce

  1. create a localVue and set an empty warn handler
const silentVue = createLocalVue();
silentVue.config.warnHandler = () => {};
  1. 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:closed
  • Created 5 years ago
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
vilbergscommented, Aug 2, 2022

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.

1reaction
eddyerburghcommented, Mar 28, 2018

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.

Read more comments on GitHub >

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

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