-
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
[PoC] VTL@next: Update to Vue 3.0 and Vue Test Utils 2.0 #137
Conversation
@afontcu What is your opinion on not going after VTU, but instead just using normal rendering of vue within jsdom? Similar to https://github.com/testing-library/react-testing-library/blob/master/src/pure.js, which doesn't depend on the |
I think VTU handles a lot of stuff internally that we can benefit from, especially given that VTU-next is being rewritten (I'm on the team) and there's some cool stuff Vue Testing Library could leverage such as plugins. |
I think I understand that, I just really like the ideological idea of having same renderer the apps use for testing and consider it highly valuable. |
If you wanted to decouple from test-utils, you could reimplement the bits you need like That said, I don't see a huge benefit in doing so - is the VTU dependency causing problems? Any benefit to moving away from it? I see VTU as a kind of low-level lib that people can, and should, build on top of. |
@lmiller1990 I was under the the false impression that VTU uses some different renderer internally, but after looking at the code it all looks fine. So sorry! I'm all good to with this approach 🙌 |
Cool! VTU v2 (for Vue 3) is actually a tiny library, around 800 lines, and it doesn't do too much. I am very excited to use testing-library with Vue 3 |
Another idea I just had:
Lots of testing libraries under the umbrella provide a |
Hum, that's a good one. Not sure if "rerender" could mean more changes in the component other than updating props – what about immediately watch elements, lifecycles…? Note that this isn't bad per se – It might lead to more realistic scenarios. The migration path would be simple, too. |
Should this even have |
yeah… it was already there when I started collaborating with the library, and I didn't want to introduce a breaking change. However, as @cilice pointed out, even React Testing Lib provides a It comes with a warning, though: "It'd probably be better if you test the component that's doing the prop updating to ensure that the props are being updated correctly" |
Hm, I like Fair enough - not against keeping this API. |
To document other testing libraries with
const { rerender } = render(<NumberDisplay number={1} />)
// re-render the same component with different props
rerender(<NumberDisplay number={2} />)
import { render } from '@marko/testing-library'
import Greeting from './greeting.marko'
const { rerender, debug } = await render(Greeting, { name: 'World' })
// re-render the same component with different props
await rerender({ name: 'Marko' })
const { container, rerender } = render(Comp, { props: { name: 'World 1' } })
expect(container.firstChild).toHaveTextContent('Hello World 1!')
rerender({ props: { name: 'World 2' } }) But I agree that it somehow feels weird, it's possible but shouldn't be prominent, just like the testing library documentation suggests. |
I'm planning on doing so but I'll wait until Vue 3 and VTU 2 releases. This way we can make sure we can iterate and align with them. |
@@ -1,23 +1,25 @@ | |||
import {render, cleanup} from '@testing-library/vue' | |||
import Vue from 'vue' | |||
test.todo('check if this test still makes sense') |
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.
re: #142
Codecov Report
@@ Coverage Diff @@
## next #137 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 1 1
Lines 70 53 -17
Branches 13 9 -4
=========================================
- Hits 70 53 -17
Continue to review full report at Codecov.
|
BREAKING CHANGE: - Snapshots are potentially different due to whitespaces. - Some options such as stubs are now moved to `global.stubs`. - Previous usage of vue instance as a parameter for the callback function is not replaced with global `config` options (for example, `global.directives`). - `isUnmounted` is gone. - `updateProps` is now called setProps to align with VTU. Some of the missing steps is to provide support to Vue Router, and also to update libraries of the ecosystem to their Vue 3 version. This is an exciting release! 🎉 It marks the first release aiming to support Vue 3 and Vue Test Utils 2. Please [head to the PR](#137) to get more information, and feel free to open up issues and PRs to fix missing features / ports 😄
BREAKING CHANGE: - Snapshots are potentially different due to whitespaces. - Some options such as stubs are now moved to `global.stubs`. - Previous usage of vue instance as a parameter for the callback function is not replaced with global `config` options (for example, `global.directives`). - `isUnmounted` is gone. - `updateProps` is now called setProps to align with VTU. Some of the missing steps is to provide support to Vue Router, and also to update libraries of the ecosystem to their Vue 3 version. This is an exciting release! 🎉 It marks the first release aiming to support Vue 3 and Vue Test Utils 2. Please [head to the PR](#137) to get more information, and feel free to open up issues and PRs to fix missing features / ports 😄
On the comment regarding It's interesting that the RTL docs have the aforementioned warning. In his series on testing JavaScript, Kent C. Dodds advocates for using the |
Hi! Yeah, it makes sense. I guess maintaining a familiar API with other testing libs make sense, as anyone coming from Vue Test Utils will still need to learn the new API. Fancy to open un a PR with the renaming? Make sure you make it point to |
I'm not as familiar with Vue as I am with React, but I can at least try to take a crack at it. In the meantime, there's another PR resolving a bug with the current |
This commit updates `imgix-component.spec.ts` to use `@testing-library/vue`'s new beta syntax. This means renaming `propsData` to `props`. The commit also updates the Vue app syntax to use the new Global API from vue 3. For more context on this change see here: testing-library/vue-testing-library#137
This commit updates `imgix-component.spec.ts` to use `@testing-library/vue`'s new beta syntax. This means renaming `propsData` to `props`. The commit also updates the Vue app syntax to use the new Global API from vue 3. For more context on this change see here: testing-library/vue-testing-library#137
This is an ongoing proof of concept to update Vue Testing Library to handle Vue 3 and Vue Test Utils 2.
Missing steps:
localVue
global
config objectmountOptions.propsData
as a way of providing propsisUnmounted
fireEvent.update
. Is it still needed?Some identified breaking changes:
stubs
are now moved toglobal.stubs
.vue
instance as a parameter for the callback function is not replaced withglobal
config options (for example,global.directives
). Not sure if (1) there's a better, less breaking way, or if (2) we should provide some sort of guidance (a console warning or so).isUnmounted
is gone.updateProps
is now calledsetProps
to align with VTU.Also: I uploadededit: gonetsconfig.json
, but I'm not 100% positive we need that?