-
Notifications
You must be signed in to change notification settings - Fork 668
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
fix #1377 string stubs dropping props #1473
Conversation
close vuejs#1377 This also fixes the component name being dropped for template stubs
Any thoughts on why it would be failing with Karma? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how to handle deprecations, we really need a process for this.
Also not sure why karma is failing, can take a look this week. It is failing in the compat
step, which runs the tests old older version of Vue. You should be able to run these locally too, there is a script (with compat) in the name. Alternatively you can just install older versions of Vue and see which one failing, starting from 2.0. There is a helper somewhere to skips tests that don't make sense for older versions (eg mainly slots had some breaking changes along the way).
Great job on this!
docs/api/mount.md
Outdated
@@ -116,7 +116,7 @@ describe('Foo', () => { | |||
it('renders a div', () => { | |||
const wrapper = mount(Foo, { | |||
stubs: { | |||
Bar: '<div class="stubbed" />', | |||
Bar: '<div class="stubbed" />', // DEPRECATED |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if it is deprecated should we just nuke it from the docs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd make an argument against that as the typescript definitions show strings as a valid option. It's very frustrating when you see something in the code, but missing in the documentation. Is there a better place to indicate that strings are deprecated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, makes sense. Not sure.... strings aren't really deprecated, just ones that are valid HTML. Could we just add a check and throw and error if the string includes <
or >
, since you can still pass something like "Text". Or are we dropping that entirely too? In that case we would change the definitions and remove string
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you were to just pass text then the vue template compiler will complain about it not being a valid template.
options.stub with mount
[vue-test-utils]: String stubs are deprecated and will be removed in future versions
[Vue warn]: Error compiling template:
Hello
- Component template requires a root element, rather than just text.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I wasn't thinking. You'd need to pass h('text')
.
Let's just drop it, and remove string
from the TS definitions if it's not longer valid? Or am I missing something 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think making breaking changes before 1.0 make a lot more sense - once we hit 1.0, deprecating things becomes a lot more difficult.
What do you think if we just deprecate it right now and add a check + warning "This is now deprecated"?
Either way let's make a decision and get this merged up! I'll leave it up to you to make the final call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deprecated as in still works for maybe the next release or two. then rip it out? I'm good with that. Really it's just to give people a chance to migrate without completely breaking any of these stubs.
Completely agree with after 1.0 it's a pain to get something out. I'd suggest that we remove this completely before 1.0 final release. Any idea on how many more beta's there will be?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just show the right methods here, and add a note below, of what used to work, but is now deprecated.
New users get to read the valid syntax, and those that are searching will find why its erroring out when they update :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. Can we get this added and merge this @Stoom , thanks for sticking with this PR for so long
I have no idea about the number of betas, since I think are unclear on what constitutes a 1.0, I think we should get Vue 3 support working (it's WIP, hopefully public alpha soon) and call whatever we have at that point the 1.0 release.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uh are we dropping string templates entirely...?
|
||
Stubs child components. Can be an Array of component names to stub, or an object. If `stubs` is an Array, every stub is `<${component name}-stub>`. | ||
|
||
Depercation note: | ||
If declaring an object, string stubs are now deprecated and will be removed in a future version. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can just drop it entirely
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we dont have versioned docs, I think it makes sense to leave it. We are deprecating, but have not yet removed it. (We saw what removing sync
did without mentioning it in the docs any more).
Maybe we can add an example what is now deprecated?
|
||
Stubs child components. Can be an Array of component names to stub, or an object. If `stubs` is an Array, every stub is `<${component name}-stub>`. | ||
|
||
Depercation note: | ||
If declaring an object, string stubs are now deprecated and will be removed in a future version. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we dont have versioned docs, I think it makes sense to leave it. We are deprecating, but have not yet removed it. (We saw what removing sync
did without mentioning it in the docs any more).
Maybe we can add an example what is now deprecated?
docs/api/mount.md
Outdated
@@ -116,7 +116,7 @@ describe('Foo', () => { | |||
it('renders a div', () => { | |||
const wrapper = mount(Foo, { | |||
stubs: { | |||
Bar: '<div class="stubbed" />', | |||
Bar: '<div class="stubbed" />', // DEPRECATED |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just show the right methods here, and add a note below, of what used to work, but is now deprecated.
New users get to read the valid syntax, and those that are searching will find why its erroring out when they update :)
@lmiller1990 @dobromir-hristov I've updated to docs. Let me know what you think, or how you would change it 🙂 |
lgtm |
What kind of change does this PR introduce? (check at least one)
Does this PR introduce a breaking change? (check one)
If yes, please describe the impact and migration path for existing applications:
The PR fulfills these requirements:
dev
branch.fix #xxx[,#xxx]
, where "xxx" is the issue number)Other information:
This deprecates using a string stub. It fixes a missing check on the compile function along with the dropping of the component name on
template
stubs.