userEvent.type gets only last letter on v12.0.9
See original GitHub issue@testing-library/user-event
version: 12.0.9- Testing Framework and version: jest@26.0.1
- DOM Environment: jsdom@16.2.2, jest-environment-jsdom@26.1.0
- node@12.14.0
Relevant code or config
name-edit.js
import React from 'react';
export const NameEdit = () => {
const [userName, setUserName] = React.useState('');
return (
<input value={userName} onChange={(e) => setUserName(e.target.value)} />
);
};
name-edit.spec.js
import React from 'react';
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { NameEdit } from './name-edit';
describe('NameEdit component specs', () => {
it('should update value when input changes', () => {
// Arrange
// Act
render(<NameEdit />);
const inputElement = screen.getByRole('textbox', {
name: '',
});
userEvent.type(inputElement, 'John');
// Assert
expect(inputElement.value).toEqual('John');
});
});
What happened:
Since I update to v12.0.9 this spec fails because it gets only last letter.
It’s working on v12.0.8
Reproduction repository:
Sandbox with v12.0.9: https://codesandbox.io/s/quizzical-surf-wpkq1 Sandbox with v12.0.8: https://codesandbox.io/s/eager-lamport-2hwhb
Issue Analytics
- State:
- Created 3 years ago
- Reactions:11
- Comments:33 (14 by maintainers)
Top Results From Across the Web
userEvent.type inputs only last character when wrapped in act
I found an issues in the user-event github and it says its resolved in version 12.0.1 but I'm on version 12.1.5 and I...
Read more >user-event v13 - Testing Library
user-event is a companion library for Testing Library that provides more. ... You should use userEvent.type if you just want to conveniently ...
Read more >Relay
Relay generates Flow or TypeScript types for each of your React components that use Relay, which represent the data that each component receives, ......
Read more >Operations Guide: TPMC-V12 & TPMC-V15 - Crestron
NOTE: Clear History only takes effect after restarting Internet Explorer. NOTE: To use the on-screen keyboard for security settings, touch Keyboard on the...
Read more >Open Source Used In slido-test 3.0 - Cisco
1.14.1 Available under license. 1.15 tokenizers 0.9.2. 1.15.1 Available under license. 1.16 types-webpack-env 1.16.3. 1.16.1 Available under license.
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
I am still suffering this error while testing next component:
Using this test:
The test doesn’t pass because expect receives ‘est input textt’ instead of ‘test input text’. If I use act function to wrap userEvent expect only receives the last letter.
What’s going on here? Does anyone know the solution to this?
Hi guys, I have a similar issue with userEvent.type, is only typed the first letter of the string. Does anyone have idea about this weird behavior?
Terminal: