-
Notifications
You must be signed in to change notification settings - Fork 110
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: update VTU to v1, update types #139
fix: update VTU to v1, update types #139
Conversation
☝️ test failed because |
src/__tests__/vuetify.js
Outdated
@@ -69,5 +69,5 @@ test('opens a menu', async () => { | |||
expect(menuItem).toBeInTheDocument() | |||
|
|||
await fireEvent.click(menuItem) | |||
expect(queryByText('menu item')).not.toBeInTheDocument() | |||
expect(queryByText('menu item')).not.toBeVisible() |
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.
Hm, did this test start to fail? 🤔 I mean, did Vuetify changed anything? I'm worried this is related to attachTo
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.
Yeah it did start to fail. When I debugged though it seemed like once menu list was open it just added display none to hide it.
Let me debug with attachToDocument
to see what it was outputting
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.
So with master
this works fine. Using debug shows that the menu item
is removed from the DOM.
However, with the latest version of VTU and attachToDocument
still show this in the DOM.
So looks like an issue with the latest release of VTU rather than use of attachTo
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.
Ok, I spent some time on this. The breaking change is actually from vue/[email protected]
-> vue/[email protected]
.
I will debug a bit more.
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.
Don't ask how I figured this out but THIS LINE is the problem. Adding it back in fixes this test.
I do not know why this was removed or what this line does.
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.
Hey! 👋 yeah, I'm currently looking into it. I started to think that toBeInTheDocument()
was actually not the right assertion.
AFAICT, Vuetify does render the element but hides it, so toBeInTheDocument()
should have passed. Now, I don't have much experience with Vuetify, so I might be wrong.
I am unable, though, to make this pass (and I think it should):
test('opens a menu', async () => {
const {getByText, queryByText} = renderWithVuetify(VuetifyDemoComponent)
const openMenuButton = getByText('open menu')
// Menu item is initially not rendered
expect(queryByText('menu item')).not.toBeInTheDocument()
await fireEvent.click(openMenuButton)
const menuItem = getByText('menu item')
expect(menuItem).toBeInTheDocument()
expect(menuItem).toBeVisible() // <-- this fails (it still has "display: none;")
await fireEvent.click(openMenuButton)
expect(menuItem).not.toBeVisible()
})
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.
@afontcu so just tried the menu in a project I have locally, the browser behaviour is:
- Mounted
v-menu
does not appear in the document - Users clicks activator. In my case a
v-text-field
.v-menu
is inserted into the DOM - User clicks activator again to close the menu.
v-menu
is still in the DOM but hasdisplay: none
So the edit to the test looks valid based on this behaviour.
Looks like the test before was reporting a false positive.
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.
Looks like the test before was reporting a false positive.
Yes! That's what I thought, too 🙌 . The snippet I posted above is currently failing, I'll try to dig a bit more and see if I can figure out why. Thought it could have something to with transitions, even though I tried with <v-menu :transition="false" />
but nothing changed.
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.
Tried a lot of different versions of this test, then figured:
"I wonder how Vuetify are testing the menu component"
Turns out the definition of this "working" is that it renders with display: none
even when clicked whilst testing with VTU.
There is a snapshot here with display: none
https://github.com/vuetifyjs/vuetify/blob/9ac1158f857fd1f531f1177ba623602973f81b55/packages/vuetify/src/components/VMenu/__tests__/__snapshots__/VMenu.spec.ts.snap#L15
With the corresponding test here https://github.com/vuetifyjs/vuetify/blob/9ac1158f857fd1f531f1177ba623602973f81b55/packages/vuetify/src/components/VMenu/__tests__/VMenu.spec.ts#L32
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.
okay, this is interesting. Now I'm leaning towards simplifying our Vuetify test (which is only aimed at showing a way of configuring VTL and Vuetify) to make it more resilient. If they are happy with display:none
, we should be, too. I'm gonna push some changes soon to this branch, and make the test pass.
Thanks for your help, @afenton90! Much appreciated :)
removes config for depracation notice as isVueInstance is now removed from internals
Does this still need work before it can be merged? I see the CI failing |
hey! yes, it is still WIP. It's been a busy week and I couldn't move it forward. I'll try to find some time, but happy to see it move forward if anyone's interested! Things I'd like to see fixed before merging this
|
@afontcu I tried a few different versions of the upgrade to see if I could figure out why the test has to be changed. Unfortunately, I have no extra information on top of my last comment here #139 (comment) which is my best theory at the moment. As for fixing of CI it seems to be specific to node 14 build. I can't see anything directly correlated with code changes in the PR. Any help to get this over the line would be appreciated. |
Looks like it was fixed in kcd-scripts v5.11.1: kentcdodds/kcd-scripts#139. Just pushed a version bump, all green now :) |
Codecov Report
@@ Coverage Diff @@
## master #139 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 1 1
Lines 68 69 +1
Branches 14 13 -1
=========================================
+ Hits 68 69 +1
Continue to review full report at Codecov.
|
Please merge?? Sounds like it's ready to go ? And our consoles are cluttered with error messages! |
I really want to figure out what's going on with Vuetify test (https://github.com/testing-library/vue-testing-library/pull/139/files#r420852127) before merging this! |
@afenton90 …fancy seeing you here! 🤣 |
🎉 This PR is included in version 5.0.3 🎉 The release is available on: Your semantic-release bot 📦🚀 |
@afontcu Just to let you know:
Maybe this belongs to the release docs here to avoid someone else having to google the solution :) After updating I also have Typescript errors coming from
I temporarily disabled the errors by adding the following to my
|
Hi! Thanks for the insights. How did your test break? Sync vs. async behaviour? Could you share the failing component / test?
you gotta love typescript errors 😅 |
@afontcu Here's the failing test:
The test failed with:
Here the tested component (I removed some parts that are unrelated to the initial render):
|
Cool! Thanks for the info. I'll add the information in the v5.0.3 release, so that people can find it easily. |
Upgrades version of
@vue/test-utils
to^1.0.1
.attachToDocument
withattachTo
and mirror default behaviourwrapper.destroy
as destroy must always be called now is usingattachTo
see@vue/test-utils
docs here.Addsconfig.showDeprecationWarnings = false
asisVueInstance
is still used internally by@vue/test-utils
and gives warnings.closes #138