Skip to content
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

Warn when users are using fireEvent.input or .change directly #166

Merged
merged 4 commits into from
Nov 17, 2020

Conversation

jhack32
Copy link
Contributor

@jhack32 jhack32 commented Nov 3, 2020

No description provided.

@codecov
Copy link

codecov bot commented Nov 3, 2020

Codecov Report

Merging #166 (2134a46) into master (04932ce) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #166   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            1         1           
  Lines           88        92    +4     
  Branches        28        30    +2     
=========================================
+ Hits            88        92    +4     
Impacted Files Coverage Δ
src/vue-testing-library.js 100.00% <100.00%> (ø)

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 04932ce...2134a46. Read the comment docs.

Copy link
Member

@afontcu afontcu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Left a small note on the specifics of the warning message


Object.keys(dtlFireEvent).forEach(key => {
fireEvent[key] = async (...args) => {
if (changeOrInputEventCalledDirectly(args[1], key)) {
console.warn(
'By using "change" or "input", there may be unexpected issues. Please use "update" for a better experience.',
Copy link
Member

@afontcu afontcu Nov 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A small suggestion to (1) write down the used event key (so people have a better feedback on where to look for) and (2) to display "fireEvent.", so that people have the exact answer right there in the warning. Any other suggestion is welcome :)

Suggested change
'By using "change" or "input", there may be unexpected issues. Please use "update" for a better experience.',
`Using "fireEvent.${key} may lead to unexpected results. Please use fireEvent.update() instead.`,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense, I'll make that change, thanks!


Object.keys(dtlFireEvent).forEach(key => {
fireEvent[key] = async (...args) => {
if (changeOrInputEventCalledDirectly(args[1], key)) {
console.warn(
`Using "fireEvent.{$key} may lead to unexpected results. Please use fireEvent.update() instead.`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should actually be

Suggested change
`Using "fireEvent.{$key} may lead to unexpected results. Please use fireEvent.update() instead.`,
`Using "fireEvent.${key} may lead to unexpected results. Please use fireEvent.update() instead.`,

so that it renders "change" or "input" 😉

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching that!

Copy link
Member

@afontcu afontcu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 neat!

@afontcu afontcu merged commit 8871d2f into testing-library:master Nov 17, 2020
@github-actions
Copy link

🎉 This PR is included in version 5.4.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions
Copy link

github-actions bot commented Jun 8, 2022

🎉 This PR is included in version 6.6.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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.

2 participants