userEvent.type(input, 'text') consistently shuffles the input
See original GitHub issue@testing-library/user-event
version: 12.0.11- Testing Framework and version: jest@24.9.0
- DOM Environment: jsdom@14.0.0 (via
jest-environment-jsdom-fourteen
)
I’m having some issues with the following test-snippet (copied from the readme with some minor modification):
test('type', () => {
render(<textarea />);
userEvent.type(screen.getByRole('textbox'), 'hey');
expect(screen.getByRole('textbox')).toHaveValue('hey');
});
When I run this, it fails with the following output:
Whatever text i input, it chucks the first input-character at the end, (i.e. 123
-> 231
).
I’m guessing this is not the expected outcome - or if so, what am I missing? 😁
I’m using fireEvent.change(screen.getByRole('textbox'), { target: { value: 'hey' } })
as a workaround for now.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:11
- Comments:18 (13 by maintainers)
Top Results From Across the Web
user-event v13 - Testing Library
You should use userEvent.type if you just want to conveniently insert some text into an input field or textarea.
Read more >userEvent.type shuffles the letters for textarea - Stack Overflow
So the letters are shuffled with no apparent reason (the first and the last letter). It works fine for the input but for...
Read more >React-testing-library: fireEvent vs userEvent - mimacom blog
As we can see, we're only creating a button and a text input with some event handlers associated to them, and we've added...
Read more >SuiteScript 2.x Map/Reduce Script Type - Oracle Help Center
The map/reduce script type is designed for scripts that need to handle large ... this output data is sent as input to the...
Read more >BrightAuthor User Guide (ver 4.6).pdf - KVMGalore
You can create three types of presentation in BrightAuthor: ... Interactive: A presentation that transitions between media based on input from a user...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Code Sandbox has now pinned JSDOM 16, but create-react-app (which is used when downloading the sandbox) is still stuck on JSDOM 14. You can work around this by installing
jest-environment-jsdom-sixteen
and adding--env jest-environment-jsdom-sixteen
to the test script until CRA is updated with Jest 26 support.I have reproduced this issue: https://codesandbox.io/s/pedantic-maxwell-wu50t?file=/src/__tests__/index.js
I’m guessing it’s something odd with React because we absolutely have tests for this:
https://github.com/testing-library/user-event/blob/26d246269058228a8255aa1ce8b3e438aa7ad3e2/src/__tests__/type.js#L109-L144
I’m not sure what the problem is, but if someone wants to investigate and figure out what we’re doing wrong that would be great.