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

Upgrade to v11.1.0 causes type method to fill Input incorrectly #309

Closed
kelvinlzhang opened this issue Jun 5, 2020 · 11 comments · Fixed by #313
Closed

Upgrade to v11.1.0 causes type method to fill Input incorrectly #309

kelvinlzhang opened this issue Jun 5, 2020 · 11 comments · Fixed by #313
Labels

Comments

@kelvinlzhang
Copy link

kelvinlzhang commented Jun 5, 2020

  • @testing-library/user-event version: 11.1.0
  • Testing Framework and version: jest on fresh react-scripts@3.4.1 app
  • DOM Environment: jest-environment-jsdom-sixteen@1.0.3

STR:

  1. Use CRA to create new app
  2. Make the following upgrades:
"@testing-library/jest-dom": "5.9.0",
"@testing-library/react": "^10.2.0",
"@testing-library/user-event": "^11.0.0", ----> "11.1.0" // breaking
"jest-environment-jsdom-sixteen": "^1.0.3",
  1. Create a component with textbox input, I just pasted in the input event example from https://testing-library.com/docs/example-input-event
  2. Use user.type instead of fireEvent to fill the input
  3. Run test with --env=jest-environment-jsdom-sixteen and observe that it fails

What happened:

test('It should keep a $ in front of the input', async () => {
  const { input } = setup()
  await user.type(input, "23")
  expect(input.value).toBe('$23')
})

Expected: "$23"
Received: "$32"

Reproduction repository: https://github.com/kelvinlzhang/user-event-test

Problem description: type fails to fill the input correctly. If you downgrade to 11.0.0 the test will pass. On another repo this exact upgrade causes an InvalidStateError and I had to reinstall jest-environment-jsdom-sixteen. This comment, #307 (comment), also explains another issue I have been unable to reproduce on a fresh app but occurred with the same dependencies.

@kentcdodds
Copy link
Member

I think I know what's going on here, I'll probably be able to fix it this morning, but if you'd like to beat me to it you're more than welcome! Even providing me with a failing test case as a PR would be helpful and welcome 😁

@krzysztof-hellostudio
Copy link

i can confirm that 11.2 still acts differently than old version, seems to be working like you had replace mode enabled in typing and occasionally loosing some letters? very strange

@krzysztof-hellostudio
Copy link

10.4.1 seems to be last version that was working more like i would expect typing to work, so appending text correctly at the end

@kentcdodds
Copy link
Member

I figured it out. Pushing a fix in a moment.

@kentcdodds
Copy link
Member

@all-contributors please add @kelvinlzhang for bugs

@allcontributors
Copy link
Contributor

@kentcdodds

I've put up a pull request to add @kelvinlzhang! 🎉

@kentcdodds
Copy link
Member

@all-contributors please add @krzysztof-hellostudio for bugs

@allcontributors
Copy link
Contributor

@kentcdodds

I've put up a pull request to add @krzysztof-hellostudio! 🎉

@kentcdodds
Copy link
Member

🎉 This issue has been resolved in version 11.2.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@tpict
Copy link

tpict commented Jun 5, 2020

Really appreciate the quick turnaround on this 😄

@kelvinlzhang
Copy link
Author

What tpict said, thanks @kentcdodds! 🚀

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 a pull request may close this issue.

4 participants