-
Notifications
You must be signed in to change notification settings - Fork 668
Cannot set config on localVue #489
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Why do you expect the warnings to be disabled? Is this a feature request? |
Well. I want to disable the validation warnings in the case I want to be verbose in what I am passing to the props. Think about a component that receives four Booleans. Expecting that all of them to be true is not a good expection to me so I would pass strings and disable the warnings locally. |
@disitec In my opinion, your testing strategy could use a little re-thinking. What is it that you are actually testing here?
My thoughts on these points:
Disabling the warnings themselves is, in my opinion, not a very good idea because you want to know if there is some expected contract or behaviour that isn't being fulfilled and could result in false positives. I recommend reading this article. It's specific to React components, but there are very similar design and testing goals between Vue and React components. |
The only point is the 5. I want to assert that my computeds (tested in separate tests, and mocked in this one) are passed as props. Maybe you’re right and this is an integration test. For me is a unit test. Parent component renders the child and passes the props. It’s its responsibility. But. I’m always willing to learn better practices and I’ll double thinking this strategy. Thanks |
Wrapping up the issue. If the props are Strings this test is a valid approach and the use case of 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',
});
}); I only want to disable IN THIS TEST, the out-of-scoped validation which are tested in other tests. Looking forward to hear about your thoughts. |
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. |
Thank you @eddyerburgh . So disabling the warnings in Vue will affect the rest of the suite. What do you recommend In this case? Maybe a child stub with the props in array format? |
Yes, I recommend a child stub with the correct props. I'm closing this issue as I can't see us changing the behavior |
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 |
@vilbergs was curious if you got anywhere with this issue outside of this issue thread? |
Sorry for the late answer. No I never dove into this more... |
Version
1.0.0-beta.12
Reproduction link
https://codesandbox.io/s/ovx3l48j3y
Steps to reproduce
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 testsThe text was updated successfully, but these errors were encountered: