userEvent.type not working with <input type="time">
See original GitHub issue@testing-library/user-event
version:12.2.0
- Testing Framework and version:
jest:26.6.0
- DOM Environment:
@testing-library/jest-dom:5.11.5
Relevant code or config
import React from 'react'
import { render, fireEvent } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
function InputNumber() {
return <input type="time" role="textbox" />
}
describe('Test <InputNumber>', () => {
it('Update with fireEvent', () => {
const { getByRole } = render(<InputNumber />)
const input = getByRole('textbox')
fireEvent.change(input, { target: { value: '01:01' } })
expect(input.value).toBe('01:01')
})
it('Update with userEvent', () => {
const { getByRole } = render(<InputNumber />)
const input = getByRole('textbox')
userEvent.type(input, '0101AM')
expect(input.value).toBe('01:01') // <- FAILS
})
})
What you did: Called userEvent.type
on <input type="time">
.
What happened: input.value
remains ""
.
Problem description: It would seem that keystrokes are not making their way to the input field. I’ve tested this under both en-US
and en-GB
locales, the result is the same.
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
userEvent.type not updating value of input in test
If you update jest to the latest version it will work. Currently, the latest jest is 26.6.3.
Read more >user-event v13 - Testing Library
import userEvent from '@testing-library/user-event' test('types into the input', () => { render( <> <label for="time">Enter a time</label>
Read more >Simplify your tests with testing-library-selector
At first glance, this solution works very well! The problem is when you have to use different types of queries for the same...
Read more >Mimicking User Interactions - Learn React Testing
Note: There is a known issue with the userEvent.type() method that was resolved in issue 12.0.4. To avoid this issue, install version 12.0.4...
Read more >userEvent.type not updating value of input in test-Reactjs
') }) Callback in test() needs to be declared as async then, of course. Link to this in the docs at time of ......
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
Amazing work. Thank you.
@gndelia, go for it 👍