Skip to content

test: 💍 add Vue tests for type, dblclick, selectoptions #153

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

Merged
merged 4 commits into from
Aug 15, 2019
Merged

Conversation

afontcu
Copy link
Member

@afontcu afontcu commented Jul 31, 2019

Hi! 👋 this is a PR to add additional tests for Vue.

  • Add tests for dblclick
  • Add tests for selectoptions
  • Add tests for type
  • (upstream) fix VTL so it doesn't mutate DOM Testing Library' fireEvent methods.
  • Fix preventDefault test for type

I can't seem to find the way to make the preventDefault test pass (link). Any help would be greatly appreciated!

Apart from that, I've only noticed small differences from React tests:

  • focus event isn't being emitted twice on selectoptions (link).
  • input/change events (link).

I guess @calebeby might want to take a look at this, too :)

@afontcu afontcu requested a review from Gpx July 31, 2019 16:02
@codecov
Copy link

codecov bot commented Jul 31, 2019

Codecov Report

Merging #153 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #153   +/-   ##
=======================================
  Coverage   96.58%   96.58%           
=======================================
  Files           1        1           
  Lines         117      117           
  Branches       27       27           
=======================================
  Hits          113      113           
  Misses          4        4

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c5df100...32aad7e. Read the comment docs.

@calebeby
Copy link
Contributor

Yeah I can take a look this afternoon (PST)

@calebeby
Copy link
Contributor

calebeby commented Aug 10, 2019

Sorry, I totally forgot to look at this, I finally remembered today!

I can't seem to find the way to make the preventDefault test pass

As far as I can tell this is because @testing-library/vue overrides @testing-library/dom's fireEvent.* methods, making them return Promise<void> rather than boolean. So whenever we import @testing-library/vue, user-event has no way of knowing whether the fired events were canceled via preventDefault()

Relevant @testing-library/vue code: https://github.com/testing-library/vue-testing-library/blob/master/src/vue-testing-library.js#L96

@calebeby
Copy link
Contributor

It's frustrating that @testing-library/vue mutates the fireEvent provided by @testing-library/dom rather than leaving the original object alone and re-exporting its own modified copy. Maybe that change could be made to @testing-library/vue?

@afontcu
Copy link
Member Author

afontcu commented Aug 10, 2019

Thank you for your insights. It makes sense. In order to test it out, I've awaited all fireEvent calls in user-event, and then awaited userEvent.type. It made the failing test pass.

I'm gonna open up a PR in VTL to propose the change you suggested. I just noticed that RTL is exporting its own version of fireEvent, instead of polluting the one from DTL.

Thanks! 🙌


Update: loading a non-modifying version of VTL into user-event also makes tests pass :)


Update 2: PR in VTL is here.

@afontcu
Copy link
Member Author

afontcu commented Aug 13, 2019

Update: VTL 2.0 has been released, and after the update, preventDefault test started passing 🙌 huge props to @calebeby for pointing out the design flaw in VTL.

@afontcu afontcu marked this pull request as ready for review August 15, 2019 08:28
@Gpx Gpx merged commit 1303a79 into master Aug 15, 2019
@Gpx Gpx deleted the add-vue-tests branch August 15, 2019 09:51
@Gpx
Copy link
Member

Gpx commented Aug 15, 2019

Thank you both for this 🎉

@Gpx
Copy link
Member

Gpx commented Aug 27, 2019

🎉 This PR is included in version 5.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@Gpx Gpx added the released label Aug 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants